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 /// Utility to display statistics about "sends" as a table on the command line. | 5 /// Utility to display statistics about "sends" as a table on the command line. |
6 library compiler.tool.stats.print_summary; | 6 library compiler.tool.stats.print_summary; |
7 | 7 |
8 import 'dart:io'; | 8 import 'dart:io'; |
9 import 'dart:convert'; | 9 import 'dart:convert'; |
10 import 'package:dart2js_info/info.dart'; | 10 import 'package:dart2js_info/info.dart'; |
11 import 'package:dart2js_info/src/table.dart'; | 11 import 'package:dart2js_info/src/table.dart'; |
12 | 12 |
13 main(args) { | 13 main(args) { |
14 var file = args.length > 0 ? args[0] : 'out.js.info.json'; | 14 var file = args.length > 0 ? args[0] : 'out.js.info.json'; |
15 var json = JSON.decode(new File(file).readAsStringSync()); | 15 var json = JSON.decode(new File(file).readAsStringSync()); |
16 var results = new AllInfo.fromJson(json); | 16 var results = new AllInfoJsonCodec().decode(json); |
17 print(formatAsTable(results)); | 17 print(formatAsTable(results)); |
18 } | 18 } |
19 | 19 |
20 /// Formats [results] as a table. | 20 /// Formats [results] as a table. |
21 String formatAsTable(AllInfo all) { | 21 String formatAsTable(AllInfo all) { |
22 var visitor = new _Counter(); | 22 var visitor = new _Counter(); |
23 all.accept(visitor); | 23 all.accept(visitor); |
24 var table = new Table(); | 24 var table = new Table(); |
25 table.declareColumn('bundle'); | 25 table.declareColumn('bundle'); |
26 | 26 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 currentBundleTotals.addFrom(measurements); | 87 currentBundleTotals.addFrom(measurements); |
88 } | 88 } |
89 } | 89 } |
90 | 90 |
91 const _groupColors = const [_YELLOW_COLOR, _NO_COLOR]; | 91 const _groupColors = const [_YELLOW_COLOR, _NO_COLOR]; |
92 | 92 |
93 const _NO_COLOR = "\x1b[0m"; | 93 const _NO_COLOR = "\x1b[0m"; |
94 const _GREEN_COLOR = "\x1b[32m"; | 94 const _GREEN_COLOR = "\x1b[32m"; |
95 const _YELLOW_COLOR = "\x1b[33m"; | 95 const _YELLOW_COLOR = "\x1b[33m"; |
96 const _WHITE_COLOR = "\x1b[37m"; | 96 const _WHITE_COLOR = "\x1b[37m"; |
OLD | NEW |