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

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

Issue 2644543004: Revert "Improvements to the kernel tree shaker." (Closed)
Patch Set: 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/language/language_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(allowTrailingOptions: true) 14 ArgParser argParser = new ArgParser()
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');
18 17
19 String usage = """ 18 String usage = """
20 Usage: treeshaker_membench [options] FILE.dill 19 Usage: treeshaker_membench [options] FILE.dart
21 20
22 Options: 21 Options:
23 ${argParser.usage} 22 ${argParser.usage}
24 """; 23 """;
25 24
26 /// Builds N copies of the tree shaker data structure for the given program. 25 /// Builds N copies of the tree shaker data structure for the given program.
27 /// Pass --print-metrics to the Dart VM to measure the memory use. 26 /// Pass --print-metrics to the Dart VM to measure the memory use.
28 main(List<String> args) { 27 main(List<String> args) {
29 if (args.length == 0) { 28 if (args.length == 0) {
30 print(usage); 29 print(usage);
31 exit(1); 30 exit(1);
32 } 31 }
33 ArgResults options = argParser.parse(args); 32 ArgResults options = argParser.parse(args);
34 if (options.rest.length != 1) { 33 if (options.rest.length != 1) {
35 print('Exactly one file should be given'); 34 print('Exactly one file should be given');
36 exit(1); 35 exit(1);
37 } 36 }
38 String filename = options.rest.single; 37 String filename = options.rest.single;
39 bool strongMode = options['strong'];
40 38
41 Program program = loadProgramFromBinary(filename); 39 Program program = loadProgramFromBinary(filename);
42 ClassHierarchy hierarchy = new ClassHierarchy(program); 40 ClassHierarchy hierarchy = new ClassHierarchy(program);
43 CoreTypes coreTypes = new CoreTypes(program); 41 CoreTypes coreTypes = new CoreTypes(program);
44 42
45 int copyCount = int.parse(options['count']); 43 int copyCount = int.parse(options['count']);
46 44
47 TreeShaker buildTreeShaker() { 45 TreeShaker buildTreeShaker() {
48 return new TreeShaker(program, 46 return new TreeShaker(program, hierarchy: hierarchy, coreTypes: coreTypes);
49 hierarchy: hierarchy, coreTypes: coreTypes, strongMode: strongMode);
50 } 47 }
51 48
52 List<TreeShaker> keepAlive = <TreeShaker>[]; 49 List<TreeShaker> keepAlive = <TreeShaker>[];
53 for (int i = 0; i < copyCount; ++i) { 50 for (int i = 0; i < copyCount; ++i) {
54 keepAlive.add(buildTreeShaker()); 51 keepAlive.add(buildTreeShaker());
55 } 52 }
56 53
57 print('$copyCount copies built'); 54 print('$copyCount copies built');
58 55
59 if (args.contains('-v')) { 56 if (args.contains('-v')) {
60 // Use of the list for something to avoid premature GC. 57 // Use of the list for something to avoid premature GC.
61 for (var treeShaker in keepAlive) { 58 for (var treeShaker in keepAlive) {
62 treeShaker.getClassRetention(hierarchy.rootClass); 59 treeShaker.getClassRetention(hierarchy.rootClass);
63 } 60 }
64 } 61 }
65 } 62 }
OLDNEW
« no previous file with comments | « pkg/kernel/test/treeshaker_dump.dart ('k') | tests/language/language_kernel.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698