| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 if (name_ != NULL) { | 60 if (name_ != NULL) { |
| 61 if (isolate_ == NULL) { | 61 if (isolate_ == NULL) { |
| 62 DeregisterWithVM(); | 62 DeregisterWithVM(); |
| 63 } else { | 63 } else { |
| 64 DeregisterWithIsolate(); | 64 DeregisterWithIsolate(); |
| 65 } | 65 } |
| 66 } | 66 } |
| 67 } | 67 } |
| 68 | 68 |
| 69 | 69 |
| 70 #ifndef PRODUCT |
| 70 static const char* UnitString(intptr_t unit) { | 71 static const char* UnitString(intptr_t unit) { |
| 71 switch (unit) { | 72 switch (unit) { |
| 72 case Metric::kCounter: return "counter"; | 73 case Metric::kCounter: return "counter"; |
| 73 case Metric::kByte: return "byte"; | 74 case Metric::kByte: return "byte"; |
| 74 default: | 75 default: |
| 75 UNREACHABLE(); | 76 UNREACHABLE(); |
| 76 } | 77 } |
| 77 UNREACHABLE(); | 78 UNREACHABLE(); |
| 78 return NULL; | 79 return NULL; |
| 79 } | 80 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 90 obj.AddProperty("unit", UnitString(unit())); | 91 obj.AddProperty("unit", UnitString(unit())); |
| 91 if (isolate_ == NULL) { | 92 if (isolate_ == NULL) { |
| 92 obj.AddFixedServiceId("vm/metrics/%s", name_); | 93 obj.AddFixedServiceId("vm/metrics/%s", name_); |
| 93 } else { | 94 } else { |
| 94 obj.AddFixedServiceId("metrics/native/%s", name_); | 95 obj.AddFixedServiceId("metrics/native/%s", name_); |
| 95 } | 96 } |
| 96 // TODO(johnmccutchan): Overflow? | 97 // TODO(johnmccutchan): Overflow? |
| 97 double value_as_double = static_cast<double>(Value()); | 98 double value_as_double = static_cast<double>(Value()); |
| 98 obj.AddProperty("value", value_as_double); | 99 obj.AddProperty("value", value_as_double); |
| 99 } | 100 } |
| 101 #endif // !PRODUCT |
| 100 | 102 |
| 101 | 103 |
| 102 char* Metric::ValueToString(int64_t value, Unit unit) { | 104 char* Metric::ValueToString(int64_t value, Unit unit) { |
| 103 Thread* thread = Thread::Current(); | 105 Thread* thread = Thread::Current(); |
| 104 ASSERT(thread != NULL); | 106 ASSERT(thread != NULL); |
| 105 Zone* zone = thread->zone(); | 107 Zone* zone = thread->zone(); |
| 106 ASSERT(zone != NULL); | 108 ASSERT(zone != NULL); |
| 107 switch (unit) { | 109 switch (unit) { |
| 108 case kCounter: | 110 case kCounter: |
| 109 return zone->PrintToString("%" Pd64 "", value); | 111 return zone->PrintToString("%" Pd64 "", value); |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 } | 338 } |
| 337 | 339 |
| 338 | 340 |
| 339 void MinMetric::SetValue(int64_t new_value) { | 341 void MinMetric::SetValue(int64_t new_value) { |
| 340 if (new_value < value()) { | 342 if (new_value < value()) { |
| 341 set_value(new_value); | 343 set_value(new_value); |
| 342 } | 344 } |
| 343 } | 345 } |
| 344 | 346 |
| 345 } // namespace dart | 347 } // namespace dart |
| OLD | NEW |