OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #ifndef RUNTIME_VM_METRICS_H_ | 5 #ifndef RUNTIME_VM_METRICS_H_ |
6 #define RUNTIME_VM_METRICS_H_ | 6 #define RUNTIME_VM_METRICS_H_ |
7 | 7 |
8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
9 | 9 |
10 namespace dart { | 10 namespace dart { |
11 | 11 |
12 class Isolate; | 12 class Isolate; |
13 class JSONStream; | 13 class JSONStream; |
14 | 14 |
15 // Metrics for each isolate. | 15 // Metrics for each isolate. |
16 #define ISOLATE_METRIC_LIST(V) \ | 16 #define ISOLATE_METRIC_LIST(V) \ |
17 V(MetricHeapOldUsed, HeapOldUsed, "heap.old.used", kByte) \ | 17 V(MetricHeapOldUsed, HeapOldUsed, "heap.old.used", kByte) \ |
18 V(MaxMetric, HeapOldUsedMax, "heap.old.used.max", kByte) \ | 18 V(MaxMetric, HeapOldUsedMax, "heap.old.used.max", kByte) \ |
19 V(MetricHeapOldCapacity, HeapOldCapacity, "heap.old.capacity", kByte) \ | 19 V(MetricHeapOldCapacity, HeapOldCapacity, "heap.old.capacity", kByte) \ |
20 V(MaxMetric, HeapOldCapacityMax, "heap.old.capacity.max", kByte) \ | 20 V(MaxMetric, HeapOldCapacityMax, "heap.old.capacity.max", kByte) \ |
21 V(MetricHeapOldExternal, HeapOldExternal, "heap.old.external", kByte) \ | 21 V(MetricHeapOldExternal, HeapOldExternal, "heap.old.external", kByte) \ |
22 V(MetricHeapNewUsed, HeapNewUsed, "heap.new.used", kByte) \ | 22 V(MetricHeapNewUsed, HeapNewUsed, "heap.new.used", kByte) \ |
23 V(MaxMetric, HeapNewUsedMax, "heap.new.used.max", kByte) \ | 23 V(MaxMetric, HeapNewUsedMax, "heap.new.used.max", kByte) \ |
24 V(MetricHeapNewCapacity, HeapNewCapacity, "heap.new.capacity", kByte) \ | 24 V(MetricHeapNewCapacity, HeapNewCapacity, "heap.new.capacity", kByte) \ |
25 V(MaxMetric, HeapNewCapacityMax, "heap.new.capacity.max", kByte) \ | 25 V(MaxMetric, HeapNewCapacityMax, "heap.new.capacity.max", kByte) \ |
26 V(MetricHeapNewExternal, HeapNewExternal, "heap.new.external", kByte) \ | 26 V(MetricHeapNewExternal, HeapNewExternal, "heap.new.external", kByte) \ |
27 V(MetricHeapUsed, HeapGlobalUsed, "heap.global.used", kByte) \ | 27 V(MetricHeapUsed, HeapGlobalUsed, "heap.global.used", kByte) \ |
28 V(MaxMetric, HeapGlobalUsedMax, "heap.global.used.max", kByte) \ | 28 V(MaxMetric, HeapGlobalUsedMax, "heap.global.used.max", kByte) |
29 | 29 |
30 #define VM_METRIC_LIST(V) \ | 30 #define VM_METRIC_LIST(V) \ |
31 V(MetricIsolateCount, IsolateCount, "vm.isolate.count", kCounter) | 31 V(MetricIsolateCount, IsolateCount, "vm.isolate.count", kCounter) |
32 | 32 |
33 class Metric { | 33 class Metric { |
34 public: | 34 public: |
35 enum Unit { | 35 enum Unit { |
36 kCounter, | 36 kCounter, |
37 kByte, | 37 kByte, |
38 }; | 38 }; |
39 | 39 |
40 Metric(); | 40 Metric(); |
41 | 41 |
42 static void InitOnce(); | 42 static void InitOnce(); |
43 | 43 |
44 static void Cleanup(); | 44 static void Cleanup(); |
45 | 45 |
46 // Initialize and register a metric for an isolate. | 46 // Initialize and register a metric for an isolate. |
47 void Init(Isolate* isolate, | 47 void Init(Isolate* isolate, |
48 const char* name, | 48 const char* name, |
49 const char* description, | 49 const char* description, |
50 Unit unit); | 50 Unit unit); |
51 | 51 |
52 // Initialize and register a metric for the VM. | 52 // Initialize and register a metric for the VM. |
53 void Init(const char* name, | 53 void Init(const char* name, const char* description, Unit unit); |
54 const char* description, | |
55 Unit unit); | |
56 | 54 |
57 virtual ~Metric(); | 55 virtual ~Metric(); |
58 | 56 |
59 #ifndef PRODUCT | 57 #ifndef PRODUCT |
60 void PrintJSON(JSONStream* stream); | 58 void PrintJSON(JSONStream* stream); |
61 #endif // !PRODUCT | 59 #endif // !PRODUCT |
62 | 60 |
63 // Returns a zone allocated string. | 61 // Returns a zone allocated string. |
64 static char* ValueToString(int64_t value, Unit unit); | 62 static char* ValueToString(int64_t value, Unit unit); |
65 | 63 |
66 // Returns a zone allocated string. | 64 // Returns a zone allocated string. |
67 char* ToString(); | 65 char* ToString(); |
68 | 66 |
69 int64_t value() const { return value_; } | 67 int64_t value() const { return value_; } |
70 void set_value(int64_t value) { value_ = value; } | 68 void set_value(int64_t value) { value_ = value; } |
71 | 69 |
72 void increment() { value_++; } | 70 void increment() { value_++; } |
73 | 71 |
74 Metric* next() const { return next_; } | 72 Metric* next() const { return next_; } |
75 void set_next(Metric* next) { | 73 void set_next(Metric* next) { next_ = next; } |
76 next_ = next; | |
77 } | |
78 | 74 |
79 const char* name() const { return name_; } | 75 const char* name() const { return name_; } |
80 const char* description() const { return description_; } | 76 const char* description() const { return description_; } |
81 Unit unit() const { return unit_; } | 77 Unit unit() const { return unit_; } |
82 | 78 |
83 // Will be NULL for Metric that is VM-global. | 79 // Will be NULL for Metric that is VM-global. |
84 Isolate* isolate() const { return isolate_; } | 80 Isolate* isolate() const { return isolate_; } |
85 | 81 |
86 static Metric* vm_head() { return vm_list_head_; } | 82 static Metric* vm_head() { return vm_list_head_; } |
87 | 83 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 | 169 |
174 | 170 |
175 class MetricHeapUsed : public Metric { | 171 class MetricHeapUsed : public Metric { |
176 protected: | 172 protected: |
177 virtual int64_t Value() const; | 173 virtual int64_t Value() const; |
178 }; | 174 }; |
179 | 175 |
180 } // namespace dart | 176 } // namespace dart |
181 | 177 |
182 #endif // RUNTIME_VM_METRICS_H_ | 178 #endif // RUNTIME_VM_METRICS_H_ |
OLD | NEW |