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

Side by Side Diff: pkg/kernel/test/treeshaker_membench.dart

Issue 2627723003: Improvements to the kernel tree shaker. (Closed)
Patch Set: Revert+Unrevert, and update status files Created 3 years, 11 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 | « pkg/kernel/test/treeshaker_dump.dart ('k') | tests/co19/co19-kernel.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env dart 1 #!/usr/bin/env dart
2 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 2 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
3 // for details. All rights reserved. Use of this source code is governed by a 3 // for details. All rights reserved. Use of this source code is governed by a
4 // BSD-style license that can be found in the LICENSE file. 4 // BSD-style license that can be found in the LICENSE file.
5 library kernel.treeshaker_membench; 5 library kernel.treeshaker_membench;
6 6
7 import 'package:kernel/kernel.dart'; 7 import 'package:kernel/kernel.dart';
8 import 'package:kernel/transformations/treeshaker.dart'; 8 import 'package:kernel/transformations/treeshaker.dart';
9 import 'package:kernel/class_hierarchy.dart'; 9 import 'package:kernel/class_hierarchy.dart';
10 import 'package:kernel/core_types.dart'; 10 import 'package:kernel/core_types.dart';
11 import 'package:args/args.dart'; 11 import 'package:args/args.dart';
12 import 'dart:io'; 12 import 'dart:io';
13 13
14 ArgParser argParser = new ArgParser() 14 ArgParser argParser = new ArgParser(allowTrailingOptions: true)
15 ..addOption('count', 15 ..addOption('count',
16 abbr: 'c', help: 'Build N copies of the tree shaker', defaultsTo: '100'); 16 abbr: 'c', help: 'Build N copies of the tree shaker', defaultsTo: '100')
17 ..addFlag('strong', help: 'Run the tree shaker in strong mode');
17 18
18 String usage = """ 19 String usage = """
19 Usage: treeshaker_membench [options] FILE.dart 20 Usage: treeshaker_membench [options] FILE.dill
20 21
21 Options: 22 Options:
22 ${argParser.usage} 23 ${argParser.usage}
23 """; 24 """;
24 25
25 /// Builds N copies of the tree shaker data structure for the given program. 26 /// Builds N copies of the tree shaker data structure for the given program.
26 /// Pass --print-metrics to the Dart VM to measure the memory use. 27 /// Pass --print-metrics to the Dart VM to measure the memory use.
27 main(List<String> args) { 28 main(List<String> args) {
28 if (args.length == 0) { 29 if (args.length == 0) {
29 print(usage); 30 print(usage);
30 exit(1); 31 exit(1);
31 } 32 }
32 ArgResults options = argParser.parse(args); 33 ArgResults options = argParser.parse(args);
33 if (options.rest.length != 1) { 34 if (options.rest.length != 1) {
34 print('Exactly one file should be given'); 35 print('Exactly one file should be given');
35 exit(1); 36 exit(1);
36 } 37 }
37 String filename = options.rest.single; 38 String filename = options.rest.single;
39 bool strongMode = options['strong'];
38 40
39 Program program = loadProgramFromBinary(filename); 41 Program program = loadProgramFromBinary(filename);
40 ClassHierarchy hierarchy = new ClassHierarchy(program); 42 ClassHierarchy hierarchy = new ClassHierarchy(program);
41 CoreTypes coreTypes = new CoreTypes(program); 43 CoreTypes coreTypes = new CoreTypes(program);
42 44
43 int copyCount = int.parse(options['count']); 45 int copyCount = int.parse(options['count']);
44 46
45 TreeShaker buildTreeShaker() { 47 TreeShaker buildTreeShaker() {
46 return new TreeShaker(program, hierarchy: hierarchy, coreTypes: coreTypes); 48 return new TreeShaker(program,
49 hierarchy: hierarchy, coreTypes: coreTypes, strongMode: strongMode);
47 } 50 }
48 51
49 List<TreeShaker> keepAlive = <TreeShaker>[]; 52 List<TreeShaker> keepAlive = <TreeShaker>[];
50 for (int i = 0; i < copyCount; ++i) { 53 for (int i = 0; i < copyCount; ++i) {
51 keepAlive.add(buildTreeShaker()); 54 keepAlive.add(buildTreeShaker());
52 } 55 }
53 56
54 print('$copyCount copies built'); 57 print('$copyCount copies built');
55 58
56 if (args.contains('-v')) { 59 if (args.contains('-v')) {
57 // Use of the list for something to avoid premature GC. 60 // Use of the list for something to avoid premature GC.
58 for (var treeShaker in keepAlive) { 61 for (var treeShaker in keepAlive) {
59 treeShaker.getClassRetention(hierarchy.rootClass); 62 treeShaker.getClassRetention(hierarchy.rootClass);
60 } 63 }
61 } 64 }
62 } 65 }
OLDNEW
« no previous file with comments | « pkg/kernel/test/treeshaker_dump.dart ('k') | tests/co19/co19-kernel.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698