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

Unified Diff: runtime/vm/service.cc

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
« no previous file with comments | « runtime/vm/metrics_test.cc ('k') | runtime/vm/vm_sources.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/service.cc
diff --git a/runtime/vm/service.cc b/runtime/vm/service.cc
index 14689e7e3dc3aa2ce07a66ad9fd8c65cfb730c5f..38d723f33df12be09b90bd3fdfb36e61542347d4 100644
--- a/runtime/vm/service.cc
+++ b/runtime/vm/service.cc
@@ -1595,6 +1595,40 @@ static RawClass* GetMetricsClass(Isolate* isolate) {
}
+static bool HandleIsolateMetricsList(Isolate* isolate, JSONStream* js) {
+ JSONObject obj(js);
+ obj.AddProperty("type", "MetricList");
+ obj.AddProperty("id", "metrics/vm");
+ {
+ JSONArray members(&obj, "members");
+ Metric* current = isolate->metrics_list_head();
+ while (current != NULL) {
+ members.AddValue(current);
+ current = current->next();
+ }
+ }
+ return true;
+}
+
+
+static bool HandleIsolateMetric(Isolate* isolate,
+ JSONStream* js,
+ const char* id) {
+ Metric* current = isolate->metrics_list_head();
+ while (current != NULL) {
+ const char* name = current->name();
+ ASSERT(name != NULL);
+ if (strcmp(name, id) == 0) {
+ current->PrintJSON(js);
+ return true;
+ }
+ current = current->next();
+ }
+ PrintError(js, "Metric %s not found\n", id);
+ return true;
+}
+
+
static bool HandleMetricsList(Isolate* isolate, JSONStream* js) {
const Class& metrics_cls = Class::Handle(isolate, GetMetricsClass(isolate));
const String& print_metrics_name =
@@ -1646,11 +1680,23 @@ static bool HandleMetrics(Isolate* isolate, JSONStream* js) {
if (js->num_arguments() == 1) {
return HandleMetricsList(isolate, js);
}
+ ASSERT(js->num_arguments() > 1);
+ const char* arg = js->GetArgument(1);
+ if (strcmp(arg, "vm") == 0) {
+ if (js->num_arguments() == 2) {
+ return HandleIsolateMetricsList(isolate, js);
+ } else {
+ if (js->num_arguments() > 3) {
+ PrintError(js, "Command too long");
+ return true;
+ }
+ return HandleIsolateMetric(isolate, js, js->GetArgument(2));
+ }
+ }
if (js->num_arguments() > 2) {
PrintError(js, "Command too long");
return true;
}
- const char* arg = js->GetArgument(1);
return HandleMetric(isolate, js, arg);
}
« no previous file with comments | « runtime/vm/metrics_test.cc ('k') | runtime/vm/vm_sources.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698