Chromium Code Reviews| Index: runtime/vm/metrics.h |
| diff --git a/runtime/vm/metrics.h b/runtime/vm/metrics.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..8c81067c51817d5ab9ac8e165586730c549145aa |
| --- /dev/null |
| +++ b/runtime/vm/metrics.h |
| @@ -0,0 +1,137 @@ |
| +// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +#ifndef VM_METRICS_H_ |
| +#define VM_METRICS_H_ |
| + |
| +#include "vm/allocation.h" |
| + |
| +namespace dart { |
| + |
| +class Isolate; |
| +class JSONStream; |
| + |
| +// Metrics for each isolate. |
| +#define ISOLATE_METRIC_LIST(V) \ |
| + V(VMMetricHeapOldUsed, HeapOldUsed, "heap.old.used", kByte) \ |
| + V(VMMetricHeapOldCapacity, HeapOldCapacity, "heap.old.capacity", kByte) \ |
| + V(VMMetricHeapOldExternal, HeapOldExternal, "heap.old.external", kByte) \ |
| + V(VMMetricHeapNewUsed, HeapNewUsed, "heap.new.used", kByte) \ |
| + V(VMMetricHeapNewCapacity, HeapNewCapacity, "heap.new.capacity", kByte) \ |
| + V(VMMetricHeapNewExternal, HeapNewExternal, "heap.new.external", kByte) \ |
| + |
| +#define VM_METRIC_LIST(V) \ |
| + V(VMMetricIsolateCount, IsolateCount, "vm.isolate.count", kCounter) \ |
| + |
| +class VMMetric { |
| + public: |
| + enum Unit { |
| + kCounter, |
| + kByte, |
| + }; |
| + |
| + VMMetric(); |
| + |
| + static void InitOnce(); |
| + |
| + // Initialize and register a counter for an isolate. |
| + void Init(Isolate* isolate, |
| + const char* name, |
| + const char* description, |
| + Unit unit); |
| + // Initialize and register a counter for the VM. |
|
koda
2014/08/13 22:43:00
The terminology is a bit awkward here: the entire
Cutch
2014/08/14 20:56:19
Done. Renamed VMMetric -> Metric.
|
| + void Init(const char* name, |
| + const char* description, |
| + Unit unit); |
| + |
| + virtual ~VMMetric(); |
| + |
| + void PrintJSON(JSONStream* stream); |
| + |
| + int64_t value() const { return value_; } |
| + void set_value(int64_t value) { value_ = value; } |
| + |
| + void increment() { value_++; } |
| + |
| + VMMetric* next() const { return next_; } |
| + void set_next(VMMetric* next) { |
| + next_ = next; |
| + } |
| + |
| + const char* name() const { return name_; } |
| + const char* description() const { return description_; } |
| + intptr_t unit() const { return unit_; } |
|
koda
2014/08/13 22:42:59
Use Unit type rather than intptr_t.
Cutch
2014/08/14 20:56:19
Done.
|
| + |
| + Isolate* isolate() const { return isolate_; } |
|
koda
2014/08/13 22:43:00
Does this need to be public? If yes, at least say
Cutch
2014/08/14 20:56:19
Done.
|
| + |
| + static VMMetric* vm_head() { return vm_list_head_; } |
| + |
| + protected: |
| + // Override to get a callback when value is serialized to JSON. |
| + // Use this for metrics that produce their value on demand. |
| + virtual int64_t Value() const { return value(); } |
| + |
| + private: |
| + Isolate* isolate_; |
| + const char* name_; |
| + const char* description_; |
| + intptr_t unit_; |
| + int64_t value_; |
| + VMMetric* next_; |
| + |
| + void RegisterWithIsolate(); |
| + void DeregisterWithIsolate(); |
| + void RegisterWithVM(); |
| + void DeregisterWithVM(); |
| + |
| + static VMMetric* vm_list_head_; |
| + DISALLOW_COPY_AND_ASSIGN(VMMetric); |
| +}; |
| + |
| + |
| +class VMMetricHeapOldUsed : public VMMetric { |
| + protected: |
| + virtual int64_t Value() const; |
| +}; |
| + |
| + |
| +class VMMetricHeapOldCapacity : public VMMetric { |
| + protected: |
| + virtual int64_t Value() const; |
| +}; |
| + |
| + |
| +class VMMetricHeapOldExternal : public VMMetric { |
| + protected: |
| + virtual int64_t Value() const; |
| +}; |
| + |
| + |
| +class VMMetricHeapNewUsed : public VMMetric { |
| + protected: |
| + virtual int64_t Value() const; |
| +}; |
| + |
| + |
| +class VMMetricHeapNewCapacity : public VMMetric { |
| + protected: |
| + virtual int64_t Value() const; |
| +}; |
| + |
| + |
| +class VMMetricHeapNewExternal : public VMMetric { |
| + protected: |
| + virtual int64_t Value() const; |
| +}; |
| + |
| + |
| +class VMMetricIsolateCount : public VMMetric { |
| + protected: |
| + virtual int64_t Value() const; |
| +}; |
| + |
| + |
| +} // namespace dart |
| + |
| +#endif // VM_METRICS_H_ |