| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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('vm_scanner_bench'); | 5 #library('vm_scanner_bench'); |
| 6 #import('scannerlib.dart'); | 6 #import('scannerlib.dart'); |
| 7 #import('scanner_implementation.dart'); | 7 #import('scanner_implementation.dart'); |
| 8 #import('scanner_bench.dart'); | 8 #import('scanner_bench.dart'); |
| 9 #import('../../../utils/utf8/utf8.dart'); | 9 #import('../../../utils/utf8/utf8.dart'); |
| 10 #import('../util/characters.dart'); |
| 10 #source('byte_strings.dart'); | 11 #source('byte_strings.dart'); |
| 11 #source('byte_array_scanner.dart'); | 12 #source('byte_array_scanner.dart'); |
| 12 | 13 |
| 13 class VmScannerBench extends ScannerBench { | 14 class VmScannerBench extends ScannerBench { |
| 14 int getBytes(String filename, void callback(List<int> bytes)) { | 15 int getBytes(String filename, void callback(List<int> bytes)) { |
| 15 var file = (new File(filename)).openSync(); | 16 var file = (new File(filename)).openSync(); |
| 16 int size = file.lengthSync(); | 17 int size = file.lengthSync(); |
| 17 List<int> bytes = new List<int>(size + 1); | 18 List<int> bytes = new List<int>(size + 1); |
| 18 file.readListSync(bytes, 0, size); | 19 file.readListSync(bytes, 0, size); |
| 19 bytes[size] = $EOF; | 20 bytes[size] = $EOF; |
| 20 file.closeSync(); | 21 file.closeSync(); |
| 21 callback(bytes); | 22 callback(bytes); |
| 22 return bytes.length - 1; | 23 return bytes.length - 1; |
| 23 } | 24 } |
| 24 | 25 |
| 25 void checkExistence(String filename) { | 26 void checkExistence(String filename) { |
| 26 File file = new File(filename); | 27 File file = new File(filename); |
| 27 if (!file.existsSync()) { | 28 if (!file.existsSync()) { |
| 28 print("no such file: ${filename}"); | 29 print("no such file: ${filename}"); |
| 29 } | 30 } |
| 30 } | 31 } |
| 31 | 32 |
| 32 Scanner makeScanner(bytes) => new ByteArrayScanner(bytes); | 33 Scanner makeScanner(bytes) => new ByteArrayScanner(bytes); |
| 33 } | 34 } |
| 34 | 35 |
| 35 main() { | 36 main() { |
| 36 new VmScannerBench().main(argv); | 37 new VmScannerBench().main(argv); |
| 37 } | 38 } |
| OLD | NEW |