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

Unified Diff: bin/deferred_library_layout.dart

Issue 2469963002: Add defer-layout tool. (Closed)
Patch Set: second round of comments Created 4 years, 1 month 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
« no previous file with comments | « README.md ('k') | pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bin/deferred_library_layout.dart
diff --git a/bin/deferred_library_layout.dart b/bin/deferred_library_layout.dart
new file mode 100644
index 0000000000000000000000000000000000000000..09caeb1578c6268d0ff27eed266464035e003aaa
--- /dev/null
+++ b/bin/deferred_library_layout.dart
@@ -0,0 +1,62 @@
+// Copyright (c) 2016, 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.
+
+/// This tool reports how code is divided among deferred chunks.
+library dart2js_info.bin.deferred_library_size;
+
+import 'dart:io';
+import 'package:dart2js_info/info.dart';
+import 'package:dart2js_info/src/util.dart';
+
+main(args) async {
+ AllInfo info = await infoFromFile(args.first);
+
+ Map<OutputUnitInfo, Map<LibraryInfo, List<BasicInfo>>> hunkMembers = {};
+ Map<LibraryInfo, Set<OutputUnitInfo>> libToHunks = {};
+ void register(BasicInfo info) {
+ var unit = info.outputUnit;
+ var lib = _libOf(info);
+ if (lib == null) return;
+ libToHunks.putIfAbsent(lib, () => new Set()).add(unit);
+ hunkMembers.putIfAbsent(unit, () => {})
+ .putIfAbsent(lib, () => []).add(info);
+ }
+
+ info.functions.forEach(register);
+ info.classes.forEach(register);
+ info.fields.forEach(register);
+ info.closures.forEach(register);
+
+ var dir = Directory.current.path;
+ hunkMembers.forEach((unit, map) {
+ print('Output unit ${unit.name ?? "main"}:');
+ if (unit.name == null || unit.name == 'main') {
+ print(' loaded by default');
+ } else {
+ print(' loaded by importing: ${unit.imports}');
+ }
+
+ print(' contains:');
+ map.forEach((lib, elements) {
+ var uri = lib.uri;
+ var shortUri = (uri.scheme == 'file' && uri.path.startsWith(dir))
+ ? uri.path.substring(dir.length + 1)
+ : '$uri';
+
+ // If the entire library is in one chunk, just report the library name
+ // otherwise report which functions are on this chunk.
+ if (libToHunks[lib].length == 1) {
+ print(' - $shortUri');
+ } else {
+ print(' - $shortUri:');
+ for (var e in elements) {
+ print(' - ${kindToString(e.kind)} ${e.name}');
+ }
+ }
+ });
+ print('');
+ });
+}
+
+_libOf(e) => e is LibraryInfo || e == null ? e : _libOf(e.parent);
« no previous file with comments | « README.md ('k') | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698