OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 // Helper file that can be used to manually test the stability of incremental | 5 // Helper file that can be used to manually test the stability of incremental |
6 // compilation. Currently this test is not run automatically. | 6 // compilation. Currently this test is not run automatically. |
7 | 7 |
8 import 'dart:async'; | 8 import 'dart:async'; |
9 | 9 |
10 import 'dart:io'; | 10 import 'dart:io'; |
11 | 11 |
12 import 'dart:profiler' show | 12 import 'dart:profiler' show |
13 UserTag; | 13 UserTag; |
14 | 14 |
| 15 import 'package:dart2js_incremental/dart2js_incremental.dart' show |
| 16 IncrementalCompiler; |
| 17 |
15 import '../memory_source_file_helper.dart' show | 18 import '../memory_source_file_helper.dart' show |
16 Compiler; | 19 Compiler; |
17 | 20 |
18 import '../memory_compiler.dart' show | 21 import '../memory_compiler.dart' show |
19 compilerFor; | 22 compilerFor; |
20 | 23 |
21 import '../../../../site/try/src/caching_compiler.dart' show | |
22 reuseCompiler; | |
23 | |
24 import 'incremental_helper.dart'; | |
25 | |
26 const bool verbose = false; | 24 const bool verbose = false; |
27 | 25 |
28 main(List<String> arguments) { | 26 main(List<String> arguments) { |
29 Stopwatch sw = new Stopwatch()..start(); | 27 Stopwatch sw = new Stopwatch()..start(); |
30 Map<String, String> sources = <String, String>{}; | 28 Map<String, String> sources = <String, String>{}; |
31 for (String argument in arguments) { | 29 for (String argument in arguments) { |
32 Uri uri = new Uri(scheme: 'memory', path: argument); | 30 Uri uri = new Uri(scheme: 'memory', path: argument); |
33 String source = | 31 String source = |
34 new File.fromUri(Uri.base.resolve(argument)).readAsStringSync(); | 32 new File.fromUri(Uri.base.resolve(argument)).readAsStringSync(); |
35 sources['${uri.path}'] = source; | 33 sources['${uri.path}'] = source; |
36 } | 34 } |
37 sw.stop(); | 35 sw.stop(); |
38 print(sw.elapsedMilliseconds); | 36 print(sw.elapsedMilliseconds); |
39 compileTests(sources); | 37 compileTests(sources); |
40 } | 38 } |
41 | 39 |
42 void compileTests(Map<String, String> sources) { | 40 void compileTests(Map<String, String> sources) { |
43 int cancellations = 0; | 41 int cancellations = 0; |
44 int testCount = 0; | 42 int testCount = 0; |
45 int skipCount = 0; | 43 int skipCount = 0; |
46 Set<String> crashes = new Set<String>(); | 44 Set<String> crashes = new Set<String>(); |
47 Compiler memoryCompiler = compilerFor(sources); | 45 Compiler memoryCompiler = compilerFor(sources); |
48 memoryCompiler.handler.verbose = verbose; | 46 memoryCompiler.handler.verbose = verbose; |
49 Compiler compiler; | 47 var options = ['--analyze-main']; |
50 var options = new List<String>.from(INCREMENTAL_OPTIONS); | |
51 if (true || verbose) options.add('--verbose'); | 48 if (true || verbose) options.add('--verbose'); |
| 49 IncrementalCompiler compiler = new IncrementalCompiler( |
| 50 libraryRoot: memoryCompiler.libraryRoot, |
| 51 inputProvider: memoryCompiler.provider, |
| 52 outputProvider: memoryCompiler.outputProvider, |
| 53 diagnosticHandler: memoryCompiler.handler, |
| 54 packageRoot: memoryCompiler.packageRoot, |
| 55 options: options); |
52 Future.forEach(sources.keys, (String path) { | 56 Future.forEach(sources.keys, (String path) { |
53 UserTag.defaultTag.makeCurrent(); | 57 UserTag.defaultTag.makeCurrent(); |
54 if (!path.endsWith('_test.dart')) return new Future.value(null); | 58 if (!path.endsWith('_test.dart')) return new Future.value(null); |
55 testCount++; | 59 testCount++; |
56 for (String brokenTest in brokenTests) { | 60 for (String brokenTest in brokenTests) { |
57 if (path.endsWith(brokenTest)) { | 61 if (path.endsWith(brokenTest)) { |
58 print('Skipped broken test $path'); | 62 print('Skipped broken test $path'); |
59 skipCount++; | 63 skipCount++; |
60 return new Future.value(null); | 64 return new Future.value(null); |
61 } | 65 } |
62 } | 66 } |
63 Stopwatch sw = new Stopwatch()..start(); | 67 Stopwatch sw = new Stopwatch()..start(); |
64 compiler = reuseCompiler( | 68 return compiler.compile(Uri.parse('memory:$path')).then((bool success) { |
65 libraryRoot: memoryCompiler.libraryRoot, | |
66 inputProvider: memoryCompiler.provider, | |
67 outputProvider: memoryCompiler.outputProvider, | |
68 diagnosticHandler: memoryCompiler.handler, | |
69 packageRoot: memoryCompiler.packageRoot, | |
70 cachedCompiler: compiler, | |
71 options: options); | |
72 return compiler.run(Uri.parse('memory:$path')).then((bool success) { | |
73 UserTag.defaultTag.makeCurrent(); | 69 UserTag.defaultTag.makeCurrent(); |
74 sw.stop(); | 70 sw.stop(); |
75 print('Compiled $path in ${sw.elapsedMilliseconds}'); | 71 print('Compiled $path in ${sw.elapsedMilliseconds}'); |
76 if (compiler.compilerWasCancelled) cancellations++; | 72 if (compiler.compilerWasCancelled) cancellations++; |
77 sw..reset()..start(); | 73 sw..reset()..start(); |
78 }).catchError((error, trace) { | 74 }).catchError((error, trace) { |
79 sw.stop(); | 75 sw.stop(); |
80 print('$error\n$trace'); | 76 print('$error\n$trace'); |
81 print('Crash when compiling $path after ${sw.elapsedMilliseconds}'); | 77 print('Crash when compiling $path after ${sw.elapsedMilliseconds}'); |
82 sw..reset()..start(); | 78 sw..reset()..start(); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 "/language/setter_declaration2_negative_test.dart", | 169 "/language/setter_declaration2_negative_test.dart", |
174 "/language/source_self_negative_test.dart", | 170 "/language/source_self_negative_test.dart", |
175 "/language/syntax_test.dart", | 171 "/language/syntax_test.dart", |
176 "/language/type_variable_bounds2_test.dart", | 172 "/language/type_variable_bounds2_test.dart", |
177 "/language/type_variable_conflict2_test.dart", | 173 "/language/type_variable_conflict2_test.dart", |
178 "/language/type_variable_field_initializer_test.dart", | 174 "/language/type_variable_field_initializer_test.dart", |
179 "/language/type_variable_nested_test.dart", | 175 "/language/type_variable_nested_test.dart", |
180 "/language/vm/reflect_core_vm_test.dart", | 176 "/language/vm/reflect_core_vm_test.dart", |
181 "/language/vm/regress_14903_test.dart", | 177 "/language/vm/regress_14903_test.dart", |
182 ]); | 178 ]); |
OLD | NEW |