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.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
4 | 4 |
5 library fasta.scanner.main; | 5 library fasta.scanner.main; |
6 | 6 |
7 import 'io.dart' show readBytesFromFileSync; | 7 import 'io.dart' show readBytesFromFileSync; |
8 | 8 |
9 import '../scanner.dart' show scan; | 9 import '../scanner.dart' show scan; |
10 | 10 |
11 scanAll(Map<Uri, List<int>> files) { | 11 scanAll(Map<Uri, List<int>> files) { |
12 Stopwatch sw = new Stopwatch()..start(); | 12 Stopwatch sw = new Stopwatch()..start(); |
13 int byteCount = 0; | 13 int byteCount = 0; |
14 files.forEach((Uri uri, List<int> bytes) { | 14 files.forEach((Uri uri, List<int> bytes) { |
15 scan(bytes); | 15 scan(bytes); |
16 byteCount += bytes.length - 1; | 16 byteCount += bytes.length - 1; |
17 }); | 17 }); |
18 sw.stop(); | 18 sw.stop(); |
19 print("Scanning files took: ${sw.elapsed}"); | 19 print("Scanning files took: ${sw.elapsed}"); |
20 print("Bytes/ms: ${byteCount/sw.elapsedMilliseconds}"); | 20 print("Bytes/ms: ${byteCount/sw.elapsedMilliseconds}"); |
21 } | 21 } |
22 | 22 |
23 main(List<String> arguments) { | 23 mainEntryPoint(List<String> arguments) { |
24 Map<Uri, List<int>> files = <Uri, List<int>>{}; | 24 Map<Uri, List<int>> files = <Uri, List<int>>{}; |
25 Stopwatch sw = new Stopwatch()..start(); | 25 Stopwatch sw = new Stopwatch()..start(); |
26 for (String name in arguments) { | 26 for (String name in arguments) { |
27 Uri uri = Uri.base.resolve(name); | 27 Uri uri = Uri.base.resolve(name); |
28 List<int> bytes = readBytesFromFileSync(uri); | 28 List<int> bytes = readBytesFromFileSync(uri); |
29 files[uri] = bytes; | 29 files[uri] = bytes; |
30 } | 30 } |
31 sw.stop(); | 31 sw.stop(); |
32 print("Reading files took: ${sw.elapsed}"); | 32 print("Reading files took: ${sw.elapsed}"); |
33 scanAll(files); | 33 scanAll(files); |
34 } | 34 } |
OLD | NEW |