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 | 4 |
5 library dart2js.serialization_impact_test; | 5 library dart2js.serialization_impact_test; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'package:async_helper/async_helper.dart'; | 8 import 'package:async_helper/async_helper.dart'; |
9 import 'package:compiler/src/commandline_options.dart'; | 9 import 'package:compiler/src/commandline_options.dart'; |
10 import 'package:compiler/src/compiler.dart'; | 10 import 'package:compiler/src/compiler.dart'; |
11 import 'package:compiler/src/filenames.dart'; | 11 import 'package:compiler/src/filenames.dart'; |
12 import '../memory_compiler.dart'; | 12 import '../memory_compiler.dart'; |
13 import 'helper.dart'; | 13 import 'helper.dart'; |
14 import 'test_helper.dart'; | 14 import 'test_helper.dart'; |
15 | 15 |
16 main(List<String> args) { | 16 main(List<String> args) { |
17 Arguments arguments = new Arguments.from(args); | 17 Arguments arguments = new Arguments.from(args); |
18 asyncTest(() async { | 18 asyncTest(() async { |
19 SerializedData serializedData = | 19 SerializedData serializedData = |
20 await serializeDartCore(arguments: arguments); | 20 await serializeDartCore(arguments: arguments); |
21 if (arguments.filename != null) { | 21 if (arguments.filename != null) { |
22 Uri entryPoint = Uri.base.resolve(nativeToUriPath(arguments.filename)); | 22 Uri entryPoint = Uri.base.resolve(nativeToUriPath(arguments.filename)); |
23 await check(serializedData, entryPoint); | 23 await check(serializedData, entryPoint); |
24 } else { | 24 } else { |
25 Uri entryPoint = Uri.parse('memory:main.dart'); | 25 Uri entryPoint = Uri.parse('memory:main.dart'); |
26 await check(serializedData, entryPoint, | 26 await check(serializedData, entryPoint, |
27 sourceFiles: {'main.dart': 'main() {}'}, | 27 sourceFiles: {'main.dart': 'main() {}'}, verbose: arguments.verbose); |
28 verbose: arguments.verbose); | |
29 } | 28 } |
30 }); | 29 }); |
31 } | 30 } |
32 | 31 |
33 Future check( | 32 Future check(SerializedData serializedData, Uri entryPoint, |
34 SerializedData serializedData, | 33 {Map<String, String> sourceFiles: const <String, String>{}, |
35 Uri entryPoint, | 34 bool verbose: false}) async { |
36 {Map<String, String> sourceFiles: const <String, String>{}, | 35 Compiler compilerNormal = |
37 bool verbose: false}) async { | 36 compilerFor(memorySourceFiles: sourceFiles, options: [Flags.analyzeAll]); |
38 | |
39 Compiler compilerNormal = compilerFor( | |
40 memorySourceFiles: sourceFiles, | |
41 options: [Flags.analyzeAll]); | |
42 compilerNormal.resolution.retainCachesForTesting = true; | 37 compilerNormal.resolution.retainCachesForTesting = true; |
43 await compilerNormal.run(entryPoint); | 38 await compilerNormal.run(entryPoint); |
44 | 39 |
45 Compiler compilerDeserialized = compilerFor( | 40 Compiler compilerDeserialized = compilerFor( |
46 memorySourceFiles: serializedData.toMemorySourceFiles(sourceFiles), | 41 memorySourceFiles: serializedData.toMemorySourceFiles(sourceFiles), |
47 resolutionInputs: serializedData.toUris(), | 42 resolutionInputs: serializedData.toUris(), |
48 options: [Flags.analyzeAll]); | 43 options: [Flags.analyzeAll]); |
49 compilerDeserialized.resolution.retainCachesForTesting = true; | 44 compilerDeserialized.resolution.retainCachesForTesting = true; |
50 await compilerDeserialized.run(entryPoint); | 45 await compilerDeserialized.run(entryPoint); |
51 | 46 |
52 checkAllImpacts(compilerNormal, compilerDeserialized, verbose: verbose); | 47 checkAllImpacts(compilerNormal, compilerDeserialized, verbose: verbose); |
53 } | 48 } |
OLD | NEW |