| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/metrics.h" | 5 #include "vm/metrics.h" |
| 6 | 6 |
| 7 #include "vm/isolate.h" | 7 #include "vm/isolate.h" |
| 8 #include "vm/json_stream.h" | 8 #include "vm/json_stream.h" |
| 9 #include "vm/native_entry.h" | 9 #include "vm/native_entry.h" |
| 10 #include "vm/runtime_entry.h" | 10 #include "vm/runtime_entry.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 return NULL; | 74 return NULL; |
| 75 } | 75 } |
| 76 | 76 |
| 77 | 77 |
| 78 void Metric::PrintJSON(JSONStream* stream) { | 78 void Metric::PrintJSON(JSONStream* stream) { |
| 79 JSONObject obj(stream); | 79 JSONObject obj(stream); |
| 80 obj.AddProperty("type", "Counter"); | 80 obj.AddProperty("type", "Counter"); |
| 81 obj.AddProperty("name", name_); | 81 obj.AddProperty("name", name_); |
| 82 obj.AddProperty("description", description_); | 82 obj.AddProperty("description", description_); |
| 83 obj.AddProperty("unit", UnitString(unit())); | 83 obj.AddProperty("unit", UnitString(unit())); |
| 84 obj.AddPropertyF("id", "metrics/vm/%s", name_); | 84 if (isolate_ == NULL) { |
| 85 obj.AddPropertyF("id", "vm/metrics/%s", name_); |
| 86 } else { |
| 87 obj.AddPropertyF("id", "metrics/native/%s", name_); |
| 88 } |
| 85 // TODO(johnmccutchan): Overflow? | 89 // TODO(johnmccutchan): Overflow? |
| 86 double value_as_double = static_cast<double>(Value()); | 90 double value_as_double = static_cast<double>(Value()); |
| 87 obj.AddProperty("value", value_as_double); | 91 obj.AddProperty("value", value_as_double); |
| 88 } | 92 } |
| 89 | 93 |
| 90 | 94 |
| 91 bool Metric::NameExists(Metric* head, const char* name) { | 95 bool Metric::NameExists(Metric* head, const char* name) { |
| 92 ASSERT(name != NULL); | 96 ASSERT(name != NULL); |
| 93 while (head != NULL) { | 97 while (head != NULL) { |
| 94 const char* metric_name = head->name(); | 98 const char* metric_name = head->name(); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 | 241 |
| 238 | 242 |
| 239 void Metric::InitOnce() { | 243 void Metric::InitOnce() { |
| 240 #define VM_METRIC_INIT(type, variable, name, unit) \ | 244 #define VM_METRIC_INIT(type, variable, name, unit) \ |
| 241 vm_metric_##variable##_.Init(name, NULL, Metric::unit); | 245 vm_metric_##variable##_.Init(name, NULL, Metric::unit); |
| 242 VM_METRIC_LIST(VM_METRIC_INIT); | 246 VM_METRIC_LIST(VM_METRIC_INIT); |
| 243 #undef VM_METRIC_INIT | 247 #undef VM_METRIC_INIT |
| 244 } | 248 } |
| 245 | 249 |
| 246 } // namespace dart | 250 } // namespace dart |
| OLD | NEW |