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

Side by Side Diff: pkg/path/test/benchmark.dart

Issue 443643002: Add benchmark to 'path' package, of the most common methods. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 4 months 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 import 'package:unittest/unittest.dart';
6 import 'package:path/path.dart' as path;
7
8 void benchmark(String name, Function func) {
9 // Warmup.
10 for (int i = 0; i < 10000; i++) {
11 for (var p in PATHS) {
12 func(p);
13 }
14 }
15 var count = 100000;
16 var sw = new Stopwatch()..start();
17 for (int i = 0; i < count; i++) {
18 for (var p in PATHS) {
19 func(p);
20 }
21 }
22 print("$name: ${count / sw.elapsedMicroseconds} iter/us (${sw.elapsed})");
23 }
24
25 main() {
26 for (var style in [path.Style.posix, path.Style.url, path.Style.windows]) {
27 group(style.name, () {
Bob Nystrom 2014/08/05 15:41:58 I'd consider not using unittest here since it does
Anders Johnsen 2014/08/06 07:42:27 Done.
28 var context = new path.Context(style: style);
29 test('basename', () {
30 benchmark('${style.name}-basename', context.basename);
31 });
32 test('basenameWithoutExtension', () {
33 benchmark('${style.name}-basenameWithoutExtension',
34 context.basenameWithoutExtension);
35 });
36 test('dirname', () {
37 benchmark('${style.name}-dirname', context.dirname);
38 });
39 test('extension', () {
40 benchmark('${style.name}-extension', context.extension);
41 });
42 test('rootPrefix', () {
43 benchmark('${style.name}-rootPrefix', context.rootPrefix);
44 });
45 test('isAbsolute', () {
46 benchmark('${style.name}-isAbsolute', context.isAbsolute);
47 });
48 test('isRelative', () {
49 benchmark('${style.name}-isRelative', context.isRelative);
50 });
51 test('isRootRelative', () {
52 benchmark('${style.name}-isRootRelative', context.isRootRelative);
53 });
54 test('normalize', () {
55 benchmark('${style.name}-normalize', context.normalize);
56 });
57 test('relative', () {
58 benchmark('${style.name}-relative', context.relative);
59 });
60 test('toUri', () {
61 benchmark('${style.name}-toUri', context.toUri);
62 });
63 test('prettyUri', () {
64 benchmark('${style.name}-prettyUri', context.prettyUri);
65 });
66 });
67 }
68 }
69
70 const PATHS = const [
71 '.',
72 '..',
73 'out/ReleaseIA32/packages',
74 '/home/user/dart/sdk/lib/indexed_db/dart2js/indexed_db_dart2js.dart',
75 'C:\\User\\me\\',
Bob Nystrom 2014/08/05 15:41:58 Nit: use a raw string here and below?
Anders Johnsen 2014/08/06 07:42:27 Done. I think we should continue to add to this l
76 '\\server\\share\\my\\folders\\some\\file.data',
nweiz 2014/08/05 19:40:33 It doesn't seem like we should be running Windows
Anders Johnsen 2014/08/06 07:42:27 Adding some url paths as well. I'd actually prefe
nweiz 2014/08/06 21:08:28 I don't think you should take out the platform-spe
Anders Johnsen 2014/08/07 08:56:10 Done.
77 ];
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698