Chromium Code Reviews| OLD | NEW |
|---|---|
| (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(VMMetricHeapOldUsed, HeapOldUsed, "heap.old.used") \ | |
| 18 V(VMMetricHeapOldCapacity, HeapOldCapacity, "heap.old.capacity") \ | |
| 19 V(VMMetricHeapOldExternal, HeapOldExternal, "heap.old.external") \ | |
| 20 V(VMMetricHeapNewUsed, HeapNewUsed, "heap.new.used") \ | |
| 21 V(VMMetricHeapNewCapacity, HeapNewCapacity, "heap.new.capacity") \ | |
| 22 V(VMMetricHeapNewExternal, HeapNewExternal, "heap.new.external") \ | |
| 23 | |
| 24 #define VM_METRIC_LIST(V) \ | |
| 25 V(VMMetricIsolateCount, IsolateCount, "vm.isolate.count") \ | |
| 26 | |
| 27 class VMMetric { | |
| 28 public: | |
| 29 VMMetric(); | |
| 30 | |
| 31 static void InitOnce(); | |
| 32 | |
| 33 // Initialize and register a counter for an isolate. | |
| 34 void Init(Isolate* isolate, const char* name, const char* description); | |
| 35 // Initialize and register a counter for the VM. | |
| 36 void Init(const char* name, const char* description); | |
| 37 | |
| 38 virtual ~VMMetric(); | |
| 39 | |
| 40 void PrintJSON(JSONStream* stream); | |
| 41 | |
| 42 // Override to get a callback when value is needed. | |
| 43 virtual int64_t Value() const { return value(); } | |
| 44 | |
| 45 int64_t value() const { return value_; } | |
|
koda
2014/08/12 22:03:03
It's confusing to have both value() and Value() in
Cutch
2014/08/13 17:50:59
Moved Value to behind 'protected:' and added comme
| |
| 46 void set_value(int64_t value) { value_ = value; } | |
| 47 | |
| 48 VMMetric* next() const { return next_; } | |
| 49 void set_next(VMMetric* next) { | |
| 50 next_ = next; | |
| 51 } | |
| 52 | |
| 53 const char* name() const { return name_; } | |
| 54 | |
| 55 Isolate* isolate() const { return isolate_; } | |
| 56 | |
| 57 static VMMetric* vm_head() { return vm_list_head_; } | |
| 58 | |
| 59 private: | |
| 60 Isolate* isolate_; | |
| 61 const char* name_; | |
| 62 const char* description_; | |
| 63 int64_t value_; | |
|
koda
2014/08/12 22:03:03
int64_t? I thought you had decided on double for a
Cutch
2014/08/13 17:50:59
On the service it is still a double but I think mo
| |
| 64 VMMetric* next_; | |
| 65 | |
| 66 void RegisterWithIsolate(); | |
| 67 void DeregisterWithIsolate(); | |
| 68 void RegisterWithVM(); | |
| 69 void DeregisterWithVM(); | |
| 70 | |
| 71 static VMMetric* vm_list_head_; | |
| 72 DISALLOW_COPY_AND_ASSIGN(VMMetric); | |
| 73 }; | |
| 74 | |
| 75 | |
| 76 class VMMetricHeapOldUsed : public VMMetric { | |
|
koda
2014/08/12 22:03:03
Please try to minimize the amount of code one must
Cutch
2014/08/13 17:50:59
A trivial isolate owned counter would require the
| |
| 77 public: | |
| 78 virtual int64_t Value() const; | |
| 79 }; | |
| 80 | |
| 81 | |
| 82 class VMMetricHeapOldCapacity : public VMMetric { | |
| 83 public: | |
| 84 virtual int64_t Value() const; | |
| 85 }; | |
| 86 | |
| 87 | |
| 88 class VMMetricHeapOldExternal : public VMMetric { | |
| 89 public: | |
| 90 virtual int64_t Value() const; | |
| 91 }; | |
| 92 | |
| 93 | |
| 94 class VMMetricHeapNewUsed : public VMMetric { | |
| 95 public: | |
| 96 virtual int64_t Value() const; | |
| 97 }; | |
| 98 | |
| 99 | |
| 100 class VMMetricHeapNewCapacity : public VMMetric { | |
| 101 public: | |
| 102 virtual int64_t Value() const; | |
| 103 }; | |
| 104 | |
| 105 | |
| 106 class VMMetricHeapNewExternal : public VMMetric { | |
| 107 public: | |
| 108 virtual int64_t Value() const; | |
| 109 }; | |
| 110 | |
| 111 | |
| 112 class VMMetricIsolateCount : public VMMetric { | |
| 113 public: | |
| 114 virtual int64_t Value() const; | |
| 115 }; | |
| 116 | |
| 117 | |
| 118 } // namespace dart | |
| 119 | |
| 120 #endif // VM_METRICS_H_ | |
| OLD | NEW |