Index: lib/src/measurements.dart |
diff --git a/lib/src/measurements.dart b/lib/src/measurements.dart |
index 499f00173aa3cad09a6a0e8a6644b83d77881f40..14c31fc6d52910c0c57fa0cd7c0def5c808b31a9 100644 |
--- a/lib/src/measurements.dart |
+++ b/lib/src/measurements.dart |
@@ -7,10 +7,7 @@ |
library dart2js_info.src.measurements; |
/// Top-level set of metrics |
-const List<Metric> _topLevelMetrics = const [ |
- Metric.functions, |
- Metric.send, |
-]; |
+const List<Metric> _topLevelMetrics = const [Metric.functions, Metric.send,]; |
/// Apply `f` on each metric in DFS order on the metric tree. [Metric.functions] |
/// and [Metric.send] are the top level metrics. See those declarations for |
@@ -35,13 +32,14 @@ class Metric { |
const Metric(this.name); |
+ factory Metric.fromName(String name) => _nameToMetricMap[name]; |
+ |
String toString() => name; |
/// Total functions in a library/package/program. Parent of |
/// [reachableFunction]. |
- static const Metric functions = const GroupedMetric('functions', const [ |
- reachableFunctions, |
- ]); |
+ static const Metric functions = |
+ const GroupedMetric('functions', const [reachableFunctions,]); |
Siggi Cherem (dart-lang)
2015/10/15 23:36:08
remove trailing comma (,) here and below.
Harry Terkelsen
2015/10/15 23:59:55
Done.
|
/// Subset of the functions that are reachable. |
static const Metric reachableFunctions = const Metric('reachable functions'); |
@@ -68,24 +66,22 @@ class Metric { |
/// |- multi-interceptor (1 of n possible interceptors) |
/// '- dynamic (any combination of the above) |
/// |
- static const Metric send = const GroupedMetric('send', const [ |
- monomorphicSend, |
- polymorphicSend, |
- ]); |
+ static const Metric send = |
+ const GroupedMetric('send', const [monomorphicSend, polymorphicSend,]); |
/// Parent of monomorphic sends, see [send] for details. |
- static const Metric monomorphicSend = const GroupedMetric('monomorphic', |
- const [ |
- staticSend, |
- superSend, |
- localSend, |
- constructorSend, |
- typeVariableSend, |
- nsmErrorSend, |
- singleNsmCallSend, |
- instanceSend, |
- interceptorSend, |
- ]); |
+ static const Metric monomorphicSend = |
+ const GroupedMetric('monomorphic', const [ |
+ staticSend, |
+ superSend, |
+ localSend, |
+ constructorSend, |
+ typeVariableSend, |
+ nsmErrorSend, |
+ singleNsmCallSend, |
+ instanceSend, |
+ interceptorSend, |
+ ]); |
/// Metric for static calls, see [send] for details. |
static const Metric staticSend = const Metric('static'); |
@@ -119,13 +115,13 @@ class Metric { |
static const Metric interceptorSend = const Metric('interceptor'); |
/// Parent of polymorphic sends, see [send] for details. |
- static const Metric polymorphicSend = const GroupedMetric('polymorphic', |
- const [ |
- multiNsmCallSend, |
- virtualSend, |
- multiInterceptorSend, |
- dynamicSend, |
- ]); |
+ static const Metric polymorphicSend = const GroupedMetric( |
+ 'polymorphic', const [ |
Siggi Cherem (dart-lang)
2015/10/15 23:36:08
I would have preferred the old formatting over wha
Harry Terkelsen
2015/10/15 23:59:55
me too
Harry Terkelsen
2015/10/16 00:05:45
looks better with the trailing comma removed
|
+ multiNsmCallSend, |
+ virtualSend, |
+ multiInterceptorSend, |
+ dynamicSend, |
+ ]); |
/// Metric for calls to noSuchMethod methods with more than one possible |
/// target, see [send] for details. |
@@ -143,14 +139,11 @@ class Metric { |
/// method. See [send] for details. |
static const Metric dynamicSend = const Metric('dynamic'); |
- String toJson() => name; |
static Map<String, Metric> _nameToMetricMap = () { |
var res = {}; |
visitAllMetrics((m, _) => res[m.name] = m); |
return res; |
}(); |
- |
- static Metric fromJson(String name) => _nameToMetricMap[name]; |
} |
/// A metric that is subdivided in smaller metrics. |
@@ -180,10 +173,12 @@ class Measurements { |
counters = <Metric, int>{}; |
const Measurements.unreachableFunction() |
- : counters = const { Metric.functions: 1}, entries = const {}, uri = null; |
+ : counters = const {Metric.functions: 1}, |
+ entries = const {}, |
+ uri = null; |
Measurements.reachableFunction([this.uri]) |
- : counters = { Metric.functions: 1, Metric.reachableFunctions: 1}, |
+ : counters = {Metric.functions: 1, Metric.reachableFunctions: 1}, |
entries = {}; |
/// Record [metric] was seen. The optional [begin] and [end] offsets are |
@@ -228,24 +223,4 @@ class Measurements { |
} |
return total == submetricTotal; |
} |
- |
- Map toJson() { |
- var jsonEntries = <String, List<Map>>{}; |
- entries.forEach((metric, values) { |
- jsonEntries[metric.toJson()] = |
- values.expand((e) => [e.begin, e.end]).toList(); |
- }); |
- var json = {'entries': jsonEntries}; |
- // TODO(sigmund): encode uri as an offset of the URIs available in the parts |
- // of the library info. |
- if (uri != null) json['sourceFile'] = '$uri'; |
- if (counters[Metric.functions] != null) { |
- json[Metric.functions.toJson()] = counters[Metric.functions]; |
- } |
- if (counters[Metric.reachableFunctions] != null) { |
- json[Metric.reachableFunctions.toJson()] = |
- counters[Metric.reachableFunctions]; |
- } |
- return json; |
- } |
} |