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 library dart.profiler; | 5 library dart.profiler; |
6 | 6 |
7 import 'dart:convert'; | 7 import 'dart:convert'; |
8 | 8 |
9 /// A UserTag can be used to group samples in the Observatory profiler. | 9 /// A UserTag can be used to group samples in the Observatory profiler. |
10 abstract class UserTag { | 10 abstract class UserTag { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 /// and use periods as separators. For example, 'a.b.c'. Uniqueness is only | 70 /// and use periods as separators. For example, 'a.b.c'. Uniqueness is only |
71 /// enforced when a Metric is registered. The name of a metric cannot contain | 71 /// enforced when a Metric is registered. The name of a metric cannot contain |
72 /// the slash ('/') character. | 72 /// the slash ('/') character. |
73 abstract class Metric { | 73 abstract class Metric { |
74 /// [name] of this metric. | 74 /// [name] of this metric. |
75 final String name; | 75 final String name; |
76 /// [description] of this metric. | 76 /// [description] of this metric. |
77 final String description; | 77 final String description; |
78 | 78 |
79 Metric(this.name, this.description) { | 79 Metric(this.name, this.description) { |
80 if (name.contains('/')) { | 80 if ((name == 'vm') || name.contains('/')) { |
81 throw new ArgumentError('Invalid Metric name.'); | 81 throw new ArgumentError('Invalid Metric name.'); |
82 } | 82 } |
| 83 |
83 } | 84 } |
84 | 85 |
85 Map _toJSON(); | 86 Map _toJSON(); |
86 } | 87 } |
87 | 88 |
88 /// A measured value with a min and max. Initial value is min. Value will | 89 /// A measured value with a min and max. Initial value is min. Value will |
89 /// be clamped to the interval [min, max]. | 90 /// be clamped to the interval [min, max]. |
90 class Gauge extends Metric { | 91 class Gauge extends Metric { |
91 final double min; | 92 final double min; |
92 final double max; | 93 final double max; |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 members.add(metric._toJSON()); | 191 members.add(metric._toJSON()); |
191 } | 192 } |
192 var map = { | 193 var map = { |
193 'type': 'MetricList', | 194 'type': 'MetricList', |
194 'id': 'metrics', | 195 'id': 'metrics', |
195 'members': members, | 196 'members': members, |
196 }; | 197 }; |
197 return JSON.encode(map); | 198 return JSON.encode(map); |
198 } | 199 } |
199 } | 200 } |
OLD | NEW |