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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: runtime/vm/metrics.h
diff --git a/runtime/vm/metrics.h b/runtime/vm/metrics.h
new file mode 100644
index 0000000000000000000000000000000000000000..e77f383d88bf89d84af16f294baf98e7bd614acf
--- /dev/null
+++ b/runtime/vm/metrics.h
@@ -0,0 +1,120 @@
+// 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") \
+ V(VMMetricHeapOldCapacity, HeapOldCapacity, "heap.old.capacity") \
+ V(VMMetricHeapOldExternal, HeapOldExternal, "heap.old.external") \
+ V(VMMetricHeapNewUsed, HeapNewUsed, "heap.new.used") \
+ V(VMMetricHeapNewCapacity, HeapNewCapacity, "heap.new.capacity") \
+ V(VMMetricHeapNewExternal, HeapNewExternal, "heap.new.external") \
+
+#define VM_METRIC_LIST(V) \
+ V(VMMetricIsolateCount, IsolateCount, "vm.isolate.count") \
+
+class VMMetric {
+ public:
+ VMMetric();
+
+ static void InitOnce();
+
+ // Initialize and register a counter for an isolate.
+ void Init(Isolate* isolate, const char* name, const char* description);
+ // Initialize and register a counter for the VM.
+ void Init(const char* name, const char* description);
+
+ virtual ~VMMetric();
+
+ void PrintJSON(JSONStream* stream);
+
+ // Override to get a callback when value is needed.
+ virtual int64_t Value() const { return value(); }
+
+ 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
+ void set_value(int64_t value) { value_ = value; }
+
+ VMMetric* next() const { return next_; }
+ void set_next(VMMetric* next) {
+ next_ = next;
+ }
+
+ const char* name() const { return name_; }
+
+ Isolate* isolate() const { return isolate_; }
+
+ static VMMetric* vm_head() { return vm_list_head_; }
+
+ private:
+ Isolate* isolate_;
+ const char* name_;
+ const char* description_;
+ 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
+ VMMetric* next_;
+
+ void RegisterWithIsolate();
+ void DeregisterWithIsolate();
+ void RegisterWithVM();
+ void DeregisterWithVM();
+
+ static VMMetric* vm_list_head_;
+ DISALLOW_COPY_AND_ASSIGN(VMMetric);
+};
+
+
+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
+ public:
+ virtual int64_t Value() const;
+};
+
+
+class VMMetricHeapOldCapacity : public VMMetric {
+ public:
+ virtual int64_t Value() const;
+};
+
+
+class VMMetricHeapOldExternal : public VMMetric {
+ public:
+ virtual int64_t Value() const;
+};
+
+
+class VMMetricHeapNewUsed : public VMMetric {
+ public:
+ virtual int64_t Value() const;
+};
+
+
+class VMMetricHeapNewCapacity : public VMMetric {
+ public:
+ virtual int64_t Value() const;
+};
+
+
+class VMMetricHeapNewExternal : public VMMetric {
+ public:
+ virtual int64_t Value() const;
+};
+
+
+class VMMetricIsolateCount : public VMMetric {
+ public:
+ virtual int64_t Value() const;
+};
+
+
+} // namespace dart
+
+#endif // VM_METRICS_H_

Powered by Google App Engine
This is Rietveld 408576698