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

Side by Side Diff: bin/library_size_split.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: 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
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 to show the size distribution of generated code among 5 /// Command-line tool to show the size distribution of generated code among
6 /// libraries. Libraries can be grouped using regular expressions. You can 6 /// libraries. Libraries can be grouped using regular expressions. You can
7 /// specify what regular expressions to use by providing a `grouping.yaml` file. 7 /// specify what regular expressions to use by providing a `grouping.yaml` file.
8 /// The format of the `grouping.yaml` file is as follows: 8 /// The format of the `grouping.yaml` file is as follows:
9 /// ```yaml 9 /// ```yaml
10 /// groups: 10 /// groups:
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 /// - regexp: "dart:.*" 52 /// - regexp: "dart:.*"
53 /// 53 ///
54 /// # If your code lives under /my/project/dir, this will match any file loaded 54 /// # If your code lives under /my/project/dir, this will match any file loaded
55 /// from a file:// url, and we use as a name the relative path to it. 55 /// from a file:// url, and we use as a name the relative path to it.
56 /// - regexp: "file:///my/project/dir/(.*)" 56 /// - regexp: "file:///my/project/dir/(.*)"
57 ///``` 57 ///```
58 /// 58 ///
59 /// This example is very similar to [defaultGrouping]. 59 /// This example is very similar to [defaultGrouping].
60 library dart2js_info.bin.library_size_split; 60 library dart2js_info.bin.library_size_split;
61 61
62 import 'dart:convert';
63 import 'dart:io'; 62 import 'dart:io';
64 import 'dart:math' show max; 63 import 'dart:math' show max;
65 64
66 import 'package:dart2js_info/info.dart'; 65 import 'package:dart2js_info/info.dart';
66 import 'package:dart2js_info/src/util.dart';
67 import 'package:yaml/yaml.dart'; 67 import 'package:yaml/yaml.dart';
68 68
69 main(args) { 69 main(args) async {
70 if (args.length < 1) { 70 if (args.length < 1) {
71 print('usage: dart tool/library_size_split.dart ' 71 print('usage: dart tool/library_size_split.dart '
72 'path-to-info.json [grouping.yaml]'); 72 'path-to-info.json [grouping.yaml]');
73 exit(1); 73 exit(1);
74 } 74 }
75 75
76 var filename = args[0]; 76 var info = await infoFromFile(args.first);
77 var json = JSON.decode(new File(filename).readAsStringSync());
78 var info = new AllInfoJsonCodec().decode(json);
79 77
80 var groupingText = 78 var groupingText =
81 args.length > 1 ? new File(args[1]).readAsStringSync() : defaultGrouping; 79 args.length > 1 ? new File(args[1]).readAsStringSync() : defaultGrouping;
82 var groupingYaml = loadYaml(groupingText); 80 var groupingYaml = loadYaml(groupingText);
83 var groups = []; 81 var groups = [];
84 for (var group in groupingYaml['groups']) { 82 for (var group in groupingYaml['groups']) {
85 groups.add(new _Group( 83 groups.add(new _Group(
86 group['name'], new RegExp(group['regexp']), group['cluster'] ?? 0)); 84 group['name'], new RegExp(group['regexp']), group['cluster'] ?? 0));
87 } 85 }
88 86
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 - { name: "Core libs", regexp: "dart:.*", cluster: 2} 202 - { name: "Core libs", regexp: "dart:.*", cluster: 2}
205 # We omitted `name` to extract the group name from the regexp directly. 203 # We omitted `name` to extract the group name from the regexp directly.
206 # Here the name is the name of the package: 204 # Here the name is the name of the package:
207 - { regexp: "package:([^/]*)", cluster: 1} 205 - { regexp: "package:([^/]*)", cluster: 1}
208 # Here the name is the url of the package and dart core libraries: 206 # Here the name is the url of the package and dart core libraries:
209 - { regexp: "package:.*"} 207 - { regexp: "package:.*"}
210 - { regexp: "dart:.*"} 208 - { regexp: "dart:.*"}
211 # Here the name is the relative path of loose files: 209 # Here the name is the relative path of loose files:
212 - { regexp: "file://${Directory.current.path}/(.*)" } 210 - { regexp: "file://${Directory.current.path}/(.*)" }
213 """; 211 """;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698