OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 /// Measurements collected about individual functions. Currently we compute | 5 /// Measurements collected about individual functions. Currently we compute |
6 /// data about "sends", to classify whether we know the target or not. | 6 /// data about "sends", to classify whether we know the target or not. |
7 library dart2js_info.src.measurements; | 7 library dart2js_info.src.measurements; |
8 | 8 |
9 /// Top-level set of metrics | 9 /// Top-level set of metrics |
10 const List<Metric> _topLevelMetrics = const [Metric.functions, Metric.send]; | 10 const List<Metric> _topLevelMetrics = const [Metric.functions, Metric.send]; |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 | 128 |
129 /// Metyric for calls to more than one possible interceptor, see [send] for | 129 /// Metyric for calls to more than one possible interceptor, see [send] for |
130 /// details. | 130 /// details. |
131 static const Metric multiInterceptorSend = const Metric('interceptor multi'); | 131 static const Metric multiInterceptorSend = const Metric('interceptor multi'); |
132 | 132 |
133 /// Metyric for dynamic calls for which we know nothing about the target | 133 /// Metyric for dynamic calls for which we know nothing about the target |
134 /// method. See [send] for details. | 134 /// method. See [send] for details. |
135 static const Metric dynamicSend = const Metric('dynamic'); | 135 static const Metric dynamicSend = const Metric('dynamic'); |
136 | 136 |
137 static Map<String, Metric> _nameToMetricMap = () { | 137 static Map<String, Metric> _nameToMetricMap = () { |
138 var res = {}; | 138 var res = <String, Metric>{}; |
139 visitAllMetrics((m, _) => res[m.name] = m); | 139 visitAllMetrics((m, _) => res[m.name] = m); |
140 return res; | 140 return res; |
141 }(); | 141 }(); |
142 } | 142 } |
143 | 143 |
144 /// A metric that is subdivided in smaller metrics. | 144 /// A metric that is subdivided in smaller metrics. |
145 class GroupedMetric extends Metric { | 145 class GroupedMetric extends Metric { |
146 final List<Metric> submetrics; | 146 final List<Metric> submetrics; |
147 | 147 |
148 const GroupedMetric(String name, this.submetrics) : super(name); | 148 const GroupedMetric(String name, this.submetrics) : super(name); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 bool checkInvariant(GroupedMetric key) { | 212 bool checkInvariant(GroupedMetric key) { |
213 int total = counters[key] ?? 0; | 213 int total = counters[key] ?? 0; |
214 int submetricTotal = 0; | 214 int submetricTotal = 0; |
215 for (var metric in key.submetrics) { | 215 for (var metric in key.submetrics) { |
216 var n = counters[metric]; | 216 var n = counters[metric]; |
217 if (n != null) submetricTotal += n; | 217 if (n != null) submetricTotal += n; |
218 } | 218 } |
219 return total == submetricTotal; | 219 return total == submetricTotal; |
220 } | 220 } |
221 } | 221 } |
OLD | NEW |