OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 /** | 5 /** |
6 * This is a helper for perf.sh. We try to run all of the Dart code in one | 6 * This is a helper for perf.sh. We try to run all of the Dart code in one |
7 * instance of the Dart VM to reduce warm-up time. | 7 * instance of the Dart VM to reduce warm-up time. |
8 */ | 8 */ |
9 library test.perf.perf; | 9 library test.perf.perf; |
10 | 10 |
11 import 'dart:async'; | 11 import 'dart:async'; |
12 import 'dart:io'; | 12 import 'dart:io'; |
13 import 'dart:json' as json; | 13 import 'dart:convert'; |
14 import 'dart:utf' show encodeUtf8; | |
15 import 'dart:isolate'; | |
16 | 14 |
17 import 'package:unittest/unittest.dart'; | 15 import 'package:unittest/unittest.dart'; |
18 import 'package:unittest/compact_vm_config.dart'; | 16 import 'package:unittest/compact_vm_config.dart'; |
19 import 'package:web_ui/dwc.dart' as dwc; | 17 import 'package:web_ui/dwc.dart' as dwc; |
| 18 import 'package:path/path.dart' as path; |
20 | 19 |
21 | 20 |
22 main() { | 21 main(args) { |
23 var args = new Options().arguments; | |
24 var pattern = new RegExp(args.length > 0 ? args[0] : '.'); | 22 var pattern = new RegExp(args.length > 0 ? args[0] : '.'); |
25 | 23 |
26 useCompactVMConfiguration(); | 24 useCompactVMConfiguration(); |
27 | 25 |
28 var lister = new Directory.fromPath(new Path('input')).list(); | 26 var lister = new Directory('input').list(); |
29 var cwd = new Path(new Directory.current().path); | 27 var cwd = Directory.current.path; |
30 var inputDir = cwd.append('input'); | 28 var inputDir = path.join(cwd, 'input'); |
31 var results = {}; | 29 var results = {}; |
32 lister.onFile = (path) { | 30 lister.onFile = (path) { |
33 if (!path.endsWith('_test.html') || !pattern.hasMatch(path)) return; | 31 if (!path.endsWith('_test.html') || !pattern.hasMatch(path)) return; |
34 var filename = new Path(path).filename; | 32 var filename = new Path(path).filename; |
35 var outDir = cwd.append('output'); | 33 var outDir = cwd.append('output'); |
36 var htmlPath = outDir.append(filename).toString(); | 34 var htmlPath = outDir.append(filename).toString(); |
37 var dartPath = outDir.append('${filename}_bootstrap.dart').toString(); | 35 var dartPath = outDir.append('${filename}_bootstrap.dart').toString(); |
38 | 36 |
39 test('drt-compile $filename', () { | 37 test('drt-compile $filename', () { |
40 expect(dwc.run(['-o', 'output/', path], printTime: false) | 38 expect(dwc.run(['-o', 'output/', path], printTime: false) |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 _extractResult(String s) { | 102 _extractResult(String s) { |
105 var match = _SCORE_REGEX.firstMatch(s); | 103 var match = _SCORE_REGEX.firstMatch(s); |
106 return (match != null) ? double.parse(match.group(1)) : null; | 104 return (match != null) ? double.parse(match.group(1)) : null; |
107 } | 105 } |
108 | 106 |
109 Future _writeFile(String path, String text) { | 107 Future _writeFile(String path, String text) { |
110 return new File(path).open(FileMode.WRITE) | 108 return new File(path).open(FileMode.WRITE) |
111 .then((file) => file.writeString(text)) | 109 .then((file) => file.writeString(text)) |
112 .then((file) => file.close()); | 110 .then((file) => file.close()); |
113 } | 111 } |
OLD | NEW |