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 import '../lib/path.dart' as path; | 5 import '../lib/path.dart' as path; |
6 | 6 |
7 void runBenchmark(String name, Function func, List files) { | 7 void runBenchmark(String name, Function func, List files) { |
8 // Warmup. | 8 // Warmup. |
9 for (int i = 0; i < 10000; i++) { | 9 for (int i = 0; i < 10000; i++) { |
10 for (var p in files) { | 10 for (var p in files) { |
(...skipping 15 matching lines...) Expand all Loading... |
26 var context = new path.Context(style: style); | 26 var context = new path.Context(style: style); |
27 var files = COMMON_PATHS.toList()..addAll(STYLE_PATHS[style]); | 27 var files = COMMON_PATHS.toList()..addAll(STYLE_PATHS[style]); |
28 | 28 |
29 void benchmark(name, func) { | 29 void benchmark(name, func) { |
30 name = style.name + '-' + name; | 30 name = style.name + '-' + name; |
31 if (args.isEmpty || args.any((arg) => name.contains(arg))) { | 31 if (args.isEmpty || args.any((arg) => name.contains(arg))) { |
32 runBenchmark(name, func, files); | 32 runBenchmark(name, func, files); |
33 } | 33 } |
34 } | 34 } |
35 | 35 |
| 36 benchmark('absolute', context.absolute); |
36 benchmark('basename', context.basename); | 37 benchmark('basename', context.basename); |
37 benchmark('basenameWithoutExtension', context.basenameWithoutExtension); | 38 benchmark('basenameWithoutExtension', context.basenameWithoutExtension); |
38 benchmark('dirname', context.dirname); | 39 benchmark('dirname', context.dirname); |
39 benchmark('extension', context.extension); | 40 benchmark('extension', context.extension); |
40 benchmark('rootPrefix', context.rootPrefix); | 41 benchmark('rootPrefix', context.rootPrefix); |
41 benchmark('isAbsolute', context.isAbsolute); | 42 benchmark('isAbsolute', context.isAbsolute); |
42 benchmark('isRelative', context.isRelative); | 43 benchmark('isRelative', context.isRelative); |
43 benchmark('isRootRelative', context.isRootRelative); | 44 benchmark('isRootRelative', context.isRootRelative); |
44 benchmark('normalize', context.normalize); | 45 benchmark('normalize', context.normalize); |
45 benchmark('relative', context.relative); | 46 benchmark('relative', context.relative); |
46 benchmark('toUri', context.toUri); | 47 benchmark('toUri', context.toUri); |
47 benchmark('prettyUri', context.prettyUri); | 48 benchmark('prettyUri', context.prettyUri); |
48 } | 49 } |
49 } | 50 } |
50 | 51 |
51 const COMMON_PATHS = const ['.', '..', 'out/ReleaseIA32/packages']; | 52 const COMMON_PATHS = const ['.', '..', 'out/ReleaseIA32/packages']; |
52 | 53 |
53 final STYLE_PATHS = { | 54 final STYLE_PATHS = { |
54 path.Style.posix: [ | 55 path.Style.posix: [ |
55 '/home/user/dart/sdk/lib/indexed_db/dart2js/indexed_db_dart2js.dart', | 56 '/home/user/dart/sdk/lib/indexed_db/dart2js/indexed_db_dart2js.dart', |
56 ], | 57 ], |
57 path.Style.url: [ | 58 path.Style.url: [ |
58 'https://example.server.org/443643002/path?top=yes#fragment', | 59 'https://example.server.org/443643002/path?top=yes#fragment', |
59 ], | 60 ], |
60 path.Style.windows: [ | 61 path.Style.windows: [ |
61 r'C:\User\me\', | 62 r'C:\User\me\', |
62 r'\\server\share\my\folders\some\file.data', | 63 r'\\server\share\my\folders\some\file.data', |
63 ], | 64 ], |
64 }; | 65 }; |
OLD | NEW |