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

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(VMMetricHeapOldUsed, HeapOldUsed, "heap.old.used", kByte) \
18 V(VMMetricHeapOldCapacity, HeapOldCapacity, "heap.old.capacity", kByte) \
19 V(VMMetricHeapOldExternal, HeapOldExternal, "heap.old.external", kByte) \
20 V(VMMetricHeapNewUsed, HeapNewUsed, "heap.new.used", kByte) \
21 V(VMMetricHeapNewCapacity, HeapNewCapacity, "heap.new.capacity", kByte) \
22 V(VMMetricHeapNewExternal, HeapNewExternal, "heap.new.external", kByte) \
23
24 #define VM_METRIC_LIST(V) \
25 V(VMMetricIsolateCount, IsolateCount, "vm.isolate.count", kCounter) \
26
27 class VMMetric {
28 public:
29 enum Unit {
30 kCounter,
31 kByte,
32 };
33
34 VMMetric();
35
36 static void InitOnce();
37
38 // Initialize and register a counter for an isolate.
39 void Init(Isolate* isolate,
40 const char* name,
41 const char* description,
42 Unit unit);
43 // 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.
44 void Init(const char* name,
45 const char* description,
46 Unit unit);
47
48 virtual ~VMMetric();
49
50 void PrintJSON(JSONStream* stream);
51
52 int64_t value() const { return value_; }
53 void set_value(int64_t value) { value_ = value; }
54
55 void increment() { value_++; }
56
57 VMMetric* next() const { return next_; }
58 void set_next(VMMetric* next) {
59 next_ = next;
60 }
61
62 const char* name() const { return name_; }
63 const char* description() const { return description_; }
64 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.
65
66 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.
67
68 static VMMetric* vm_head() { return vm_list_head_; }
69
70 protected:
71 // Override to get a callback when value is serialized to JSON.
72 // Use this for metrics that produce their value on demand.
73 virtual int64_t Value() const { return value(); }
74
75 private:
76 Isolate* isolate_;
77 const char* name_;
78 const char* description_;
79 intptr_t unit_;
80 int64_t value_;
81 VMMetric* next_;
82
83 void RegisterWithIsolate();
84 void DeregisterWithIsolate();
85 void RegisterWithVM();
86 void DeregisterWithVM();
87
88 static VMMetric* vm_list_head_;
89 DISALLOW_COPY_AND_ASSIGN(VMMetric);
90 };
91
92
93 class VMMetricHeapOldUsed : public VMMetric {
94 protected:
95 virtual int64_t Value() const;
96 };
97
98
99 class VMMetricHeapOldCapacity : public VMMetric {
100 protected:
101 virtual int64_t Value() const;
102 };
103
104
105 class VMMetricHeapOldExternal : public VMMetric {
106 protected:
107 virtual int64_t Value() const;
108 };
109
110
111 class VMMetricHeapNewUsed : public VMMetric {
112 protected:
113 virtual int64_t Value() const;
114 };
115
116
117 class VMMetricHeapNewCapacity : public VMMetric {
118 protected:
119 virtual int64_t Value() const;
120 };
121
122
123 class VMMetricHeapNewExternal : public VMMetric {
124 protected:
125 virtual int64_t Value() const;
126 };
127
128
129 class VMMetricIsolateCount : public VMMetric {
130 protected:
131 virtual int64_t Value() const;
132 };
133
134
135 } // namespace dart
136
137 #endif // VM_METRICS_H_
OLDNEW
« no previous file with comments | « runtime/vm/json_stream.cc ('k') | runtime/vm/metrics.cc » ('j') | runtime/vm/metrics.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698