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

Unified 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 side-by-side diff with in-line comments
Download patch
« lib/src/table.dart ('K') | « lib/src/table.dart ('k') | pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/util.dart
diff --git a/lib/src/util.dart b/lib/src/util.dart
index e30ba1799e1e095943a7ef3e7db3d5b78cac5405..1b8a0847b2373b6899b3a791db9c428289b01bd4 100644
--- a/lib/src/util.dart
+++ b/lib/src/util.dart
@@ -1,4 +1,8 @@
-library compiler.tool.util;
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library dart2js_info.src.util;
import 'package:dart2js_info/info.dart';
import 'graph.dart';
@@ -73,3 +77,50 @@ pad(value, n, {bool right: false}) {
var pad = ' ' * (n - s.length);
return right ? '$s$pad' : '$pad$s';
}
+
+/// Color-highlighted string used mainly to debug invariants.
+String recursiveDiagnosticString(Measurements measurements, Metric metric) {
+ var sb = new StringBuffer();
+ helper(Metric m) {
+ int value = measurements.counters[m];
+ if (value == null) value = 0;
+ if (m is! GroupedMetric) {
+ sb.write(value);
+ sb.write(' ${m.name}');
+ return;
+ }
+ GroupedMetric group = m;
+
+ int expected = 0;
+ for (var sub in group.submetrics) {
+ var n = measurements.counters[sub];
+ if (n != null) expected += n;
+ }
+ if (value == expected) {
+ sb.write('');
+ sb.write(value);
+ } else {
+ sb.write('');
+ sb.write(value);
+ sb.write('[');
+ sb.write(expected);
+ sb.write(']');
+ }
+ sb.write('');
+ sb.write(' ${group.name}');
+
+ bool first = true;
+ sb.write('(');
+ for (var sub in group.submetrics) {
+ if (first) {
+ first = false;
+ } else {
+ sb.write(' + ');
+ }
+ helper(sub);
+ }
+ sb.write(')');
+ }
+ helper(metric);
+ return sb.toString();
+}
« 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