Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Side by Side Diff: runtime/vm/metrics.h

Issue 464953002: Add VMMetric and some sample metrics (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 #ifndef VM_METRICS_H_
6 #define VM_METRICS_H_
7
8 #include "vm/allocation.h"
9
10 namespace dart {
11
12 class Isolate;
13 class JSONStream;
14
15 // Metrics for each isolate.
16 #define ISOLATE_METRIC_LIST(V) \
17 V(MetricHeapOldUsed, HeapOldUsed, "heap.old.used", kByte) \
18 V(MetricHeapOldCapacity, HeapOldCapacity, "heap.old.capacity", kByte) \
19 V(MetricHeapOldExternal, HeapOldExternal, "heap.old.external", kByte) \
20 V(MetricHeapNewUsed, HeapNewUsed, "heap.new.used", kByte) \
21 V(MetricHeapNewCapacity, HeapNewCapacity, "heap.new.capacity", kByte) \
22 V(MetricHeapNewExternal, HeapNewExternal, "heap.new.external", kByte) \
23
24 #define VM_METRIC_LIST(V) \
25 V(MetricIsolateCount, IsolateCount, "vm.isolate.count", kCounter) \
26
27 class Metric {
28 public:
29 enum Unit {
30 kCounter,
31 kByte,
32 };
33
34 Metric();
35
36 static void InitOnce();
37
38 // Initialize and register a metric for an isolate.
39 void Init(Isolate* isolate,
40 const char* name,
41 const char* description,
42 Unit unit);
43
44 // Initialize and register a metric for the VM.
45 void Init(const char* name,
46 const char* description,
47 Unit unit);
48
49 virtual ~Metric();
50
51 void PrintJSON(JSONStream* stream);
52
53 int64_t value() const { return value_; }
54 void set_value(int64_t value) { value_ = value; }
55
56 void increment() { value_++; }
57
58 Metric* next() const { return next_; }
59 void set_next(Metric* next) {
60 next_ = next;
61 }
62
63 const char* name() const { return name_; }
64 const char* description() const { return description_; }
65 Unit unit() const { return unit_; }
66
67 // Will be NULL for Metric that is VM-global.
68 Isolate* isolate() const { return isolate_; }
69
70 static Metric* vm_head() { return vm_list_head_; }
71
72 protected:
73 // Override to get a callback when value is serialized to JSON.
74 // Use this for metrics that produce their value on demand.
75 virtual int64_t Value() const { return value(); }
76
77 private:
78 Isolate* isolate_;
79 const char* name_;
80 const char* description_;
81 Unit unit_;
82 int64_t value_;
83 Metric* next_;
84
85 static bool NameExists(Metric* head, const char* name);
86
87 void RegisterWithIsolate();
88 void DeregisterWithIsolate();
89 void RegisterWithVM();
90 void DeregisterWithVM();
91
92 static Metric* vm_list_head_;
93 DISALLOW_COPY_AND_ASSIGN(Metric);
94 };
95
96
97 class MetricHeapOldUsed : public Metric {
98 protected:
99 virtual int64_t Value() const;
100 };
101
102
103 class MetricHeapOldCapacity : public Metric {
104 protected:
105 virtual int64_t Value() const;
106 };
107
108
109 class MetricHeapOldExternal : public Metric {
110 protected:
111 virtual int64_t Value() const;
112 };
113
114
115 class MetricHeapNewUsed : public Metric {
116 protected:
117 virtual int64_t Value() const;
118 };
119
120
121 class MetricHeapNewCapacity : public Metric {
122 protected:
123 virtual int64_t Value() const;
124 };
125
126
127 class MetricHeapNewExternal : public Metric {
128 protected:
129 virtual int64_t Value() const;
130 };
131
132
133 class MetricIsolateCount : public Metric {
134 protected:
135 virtual int64_t Value() const;
136 };
137
138
139 } // namespace dart
140
141 #endif // VM_METRICS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698