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

Side by Side Diff: bin/function_size_analysis.dart

Issue 2201903004: add tool to get breakdown of deferred libraries by size (Closed) Base URL: git@github.com:dart-lang/dart2js_info.git@master
Patch Set: add TODO Created 4 years, 4 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
« no previous file with comments | « bin/deferred_library_size.dart ('k') | bin/library_size_split.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 /// Command-line tool presenting how much each function contributes to the total 5 /// Command-line tool presenting how much each function contributes to the total
6 /// code. 6 /// code.
7 library compiler.tool.live_code_size_analysis; 7 library compiler.tool.live_code_size_analysis;
8 8
9 import 'dart:convert';
10 import 'dart:io';
11 import 'dart:math' as math; 9 import 'dart:math' as math;
12 10
13 import 'package:dart2js_info/info.dart'; 11 import 'package:dart2js_info/info.dart';
14 import 'package:dart2js_info/src/graph.dart'; 12 import 'package:dart2js_info/src/graph.dart';
15 import 'package:dart2js_info/src/util.dart'; 13 import 'package:dart2js_info/src/util.dart';
16 14
17 main(args) { 15 main(args) async {
18 var json = JSON.decode(new File(args[0]).readAsStringSync()); 16 var info = await infoFromFile(args.first);
19 var info = new AllInfoJsonCodec().decode(json);
20 showCodeDistribution(info); 17 showCodeDistribution(info);
21 } 18 }
22 19
23 showCodeDistribution(AllInfo info, 20 showCodeDistribution(AllInfo info,
24 {bool filter(Info info), bool showLibrarySizes: false}) { 21 {bool filter(Info info), bool showLibrarySizes: false}) {
25 var realTotal = info.program.size; 22 var realTotal = info.program.size;
26 if (filter == null) filter = (i) => true; 23 if (filter == null) filter = (i) => true;
27 var reported = [] 24 var reported = []
28 ..addAll(info.functions.where(filter)) 25 ..addAll(info.functions.where(filter))
29 ..addAll(info.fields.where(filter)); 26 ..addAll(info.fields.where(filter));
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 154
158 _showElement(String name, int size, int dominatedSize, int maxSize, int total) { 155 _showElement(String name, int size, int dominatedSize, int maxSize, int total) {
159 var percent = (size * 100 / total).toStringAsFixed(2); 156 var percent = (size * 100 / total).toStringAsFixed(2);
160 var minPercent = (dominatedSize * 100 / total).toStringAsFixed(2); 157 var minPercent = (dominatedSize * 100 / total).toStringAsFixed(2);
161 var maxPercent = (maxSize * 100 / total).toStringAsFixed(2); 158 var maxPercent = (maxSize * 100 / total).toStringAsFixed(2);
162 print('${pad(size, 8)} ${pad(percent, 6)}% ' 159 print('${pad(size, 8)} ${pad(percent, 6)}% '
163 '${pad(dominatedSize, 10)} ${pad(minPercent, 6)}% ' 160 '${pad(dominatedSize, 10)} ${pad(minPercent, 6)}% '
164 '${pad(maxSize, 10)} ${pad(maxPercent, 6)}% ' 161 '${pad(maxSize, 10)} ${pad(maxPercent, 6)}% '
165 '$name'); 162 '$name');
166 } 163 }
OLDNEW
« no previous file with comments | « bin/deferred_library_size.dart ('k') | bin/library_size_split.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698