Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(665)

Side by Side Diff: benchmark/benchmark.dart

Issue 1455003002: Optimize absolute() and normalize(). (Closed) Base URL: git@github.com:dart-lang/path@master
Patch Set: Code review changes Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « CHANGELOG.md ('k') | lib/src/context.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 };
OLDNEW
« no previous file with comments | « CHANGELOG.md ('k') | lib/src/context.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698