Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Side by Side Diff: lib/src/util.dart

Issue 1372333002: Add measurements and send-metrics to dart2js's info. (Closed) Base URL: git@github.com:dart-lang/dart2js_info.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 library compiler.tool.util; 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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library dart2js_info.src.util;
2 6
3 import 'package:dart2js_info/info.dart'; 7 import 'package:dart2js_info/info.dart';
4 import 'graph.dart'; 8 import 'graph.dart';
5 9
6 /// Computes a graph of dependencies from [info]. 10 /// Computes a graph of dependencies from [info].
7 Graph<Info> graphFromInfo(AllInfo info) { 11 Graph<Info> graphFromInfo(AllInfo info) {
8 print(' info: dependency graph information is work in progress and' 12 print(' info: dependency graph information is work in progress and'
9 ' might be incomplete'); 13 ' might be incomplete');
10 // Note: we are combining dependency information that is computed in two ways 14 // Note: we are combining dependency information that is computed in two ways
11 // (functionInfo.uses vs allInfo.dependencies). 15 // (functionInfo.uses vs allInfo.dependencies).
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 return sb.toString(); 70 return sb.toString();
67 } 71 }
68 72
69 /// Produce a string containing [value] padded with white space up to [n] chars. 73 /// Produce a string containing [value] padded with white space up to [n] chars.
70 pad(value, n, {bool right: false}) { 74 pad(value, n, {bool right: false}) {
71 var s = '$value'; 75 var s = '$value';
72 if (s.length >= n) return s; 76 if (s.length >= n) return s;
73 var pad = ' ' * (n - s.length); 77 var pad = ' ' * (n - s.length);
74 return right ? '$s$pad' : '$pad$s'; 78 return right ? '$s$pad' : '$pad$s';
75 } 79 }
80
81 /// Color-highlighted string used mainly to debug invariants.
82 String recursiveDiagnosticString(Measurements measurements, Metric metric) {
83 var sb = new StringBuffer();
84 helper(Metric m) {
85 int value = measurements.counters[m];
86 if (value == null) value = 0;
87 if (m is! GroupedMetric) {
88 sb.write(value);
89 sb.write(' ${m.name}');
90 return;
91 }
92 GroupedMetric group = m;
93
94 int expected = 0;
95 for (var sub in group.submetrics) {
96 var n = measurements.counters[sub];
97 if (n != null) expected += n;
98 }
99 if (value == expected) {
100 sb.write('');
101 sb.write(value);
102 } else {
103 sb.write('');
104 sb.write(value);
105 sb.write('[');
106 sb.write(expected);
107 sb.write(']');
108 }
109 sb.write('');
110 sb.write(' ${group.name}');
111
112 bool first = true;
113 sb.write('(');
114 for (var sub in group.submetrics) {
115 if (first) {
116 first = false;
117 } else {
118 sb.write(' + ');
119 }
120 helper(sub);
121 }
122 sb.write(')');
123 }
124 helper(metric);
125 return sb.toString();
126 }
OLDNEW
« lib/src/table.dart ('K') | « lib/src/table.dart ('k') | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698