| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 library kernel.treeshaker_bench; | 4 library kernel.treeshaker_bench; |
| 5 | 5 |
| 6 import 'dart:io'; | 6 import 'dart:io'; |
| 7 | 7 |
| 8 import 'package:args/args.dart'; | 8 import 'package:args/args.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'; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 exit(1); | 43 exit(1); |
| 44 } | 44 } |
| 45 String filename = options.rest.single; | 45 String filename = options.rest.single; |
| 46 bool strongMode = options['strong']; | 46 bool strongMode = options['strong']; |
| 47 | 47 |
| 48 Program program = loadProgramFromBinary(filename); | 48 Program program = loadProgramFromBinary(filename); |
| 49 | 49 |
| 50 ClassHierarchy buildClassHierarchy() { | 50 ClassHierarchy buildClassHierarchy() { |
| 51 return options['basic'] | 51 return options['basic'] |
| 52 ? new BasicClassHierarchy(program) | 52 ? new BasicClassHierarchy(program) |
| 53 : new ClassHierarchy(program); | 53 : new ClosedWorldClassHierarchy(program); |
| 54 } | 54 } |
| 55 | 55 |
| 56 CoreTypes coreTypes = new CoreTypes(program); | 56 CoreTypes coreTypes = new CoreTypes(program); |
| 57 | 57 |
| 58 var watch = new Stopwatch()..start(); | 58 var watch = new Stopwatch()..start(); |
| 59 ClassHierarchy sharedClassHierarchy = buildClassHierarchy(); | 59 ClassHierarchy sharedClassHierarchy = buildClassHierarchy(); |
| 60 int coldHierarchyTime = watch.elapsedMicroseconds; | 60 int coldHierarchyTime = watch.elapsedMicroseconds; |
| 61 var shaker = new TreeShaker(coreTypes, sharedClassHierarchy, program, | 61 var shaker = new TreeShaker(coreTypes, sharedClassHierarchy, program, |
| 62 strongMode: strongMode); | 62 strongMode: strongMode); |
| 63 if (options['diagnose']) { | 63 if (options['diagnose']) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 88 | 88 |
| 89 var coldShakingMs = coldTreeShakingTime ~/ 1000; | 89 var coldShakingMs = coldTreeShakingTime ~/ 1000; |
| 90 var coldHierarchyMs = coldHierarchyTime ~/ 1000; | 90 var coldHierarchyMs = coldHierarchyTime ~/ 1000; |
| 91 var hotShakingMs = hotTreeShakingTime ~/ 1000; | 91 var hotShakingMs = hotTreeShakingTime ~/ 1000; |
| 92 var hotHierarchyMs = hotHierarchyTime ~/ 1000; | 92 var hotHierarchyMs = hotHierarchyTime ~/ 1000; |
| 93 | 93 |
| 94 print(''' | 94 print(''' |
| 95 build.cold $coldShakingMs ms ($coldHierarchyMs ms from hierarchy) | 95 build.cold $coldShakingMs ms ($coldHierarchyMs ms from hierarchy) |
| 96 build.hot $hotShakingMs ms ($hotHierarchyMs ms from hierarchy)'''); | 96 build.hot $hotShakingMs ms ($hotHierarchyMs ms from hierarchy)'''); |
| 97 } | 97 } |
| OLD | NEW |