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

Unified Diff: packages/path/benchmark/benchmark.dart

Issue 1521693002: Roll Observatory deps (charted -> ^0.3.0) (Closed) Base URL: https://chromium.googlesource.com/external/github.com/dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « packages/path/CHANGELOG.md ('k') | packages/path/lib/path.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: packages/path/benchmark/benchmark.dart
diff --git a/packages/path/benchmark/benchmark.dart b/packages/path/benchmark/benchmark.dart
index 419eee0fda0768cfdd0080bf0c806046ed18021d..4285e653e85191507101a6b290d37b54c7a10283 100644
--- a/packages/path/benchmark/benchmark.dart
+++ b/packages/path/benchmark/benchmark.dart
@@ -21,18 +21,48 @@ void runBenchmark(String name, Function func, List files) {
print("$name: ${count / sw.elapsedMicroseconds} iter/us (${sw.elapsed})");
}
+void runBenchmarkTwoArgs(String name, Function func, List files) {
+ // Warmup.
+ for (int i = 0; i < 1000; i++) {
+ for (var file1 in files) {
+ for (var file2 in files) {
+ func(file1, file2);
+ }
+ }
+ }
+
+ var count = 10000;
+ var sw = new Stopwatch()..start();
+ for (int i = 0; i < count; i++) {
+ for (var file1 in files) {
+ for (var file2 in files) {
+ func(file1, file2);
+ }
+ }
+ }
+ print("$name: ${count / sw.elapsedMicroseconds} iter/us (${sw.elapsed})");
+}
+
main(args) {
for (var style in [path.Style.posix, path.Style.url, path.Style.windows]) {
var context = new path.Context(style: style);
var files = COMMON_PATHS.toList()..addAll(STYLE_PATHS[style]);
- void benchmark(name, func) {
+ benchmark(name, func) {
name = style.name + '-' + name;
if (args.isEmpty || args.any((arg) => name.contains(arg))) {
runBenchmark(name, func, files);
}
}
+ benchmarkTwoArgs(name, func) {
+ name = style.name + '-' + name + '-two';
+ if (args.isEmpty || args.any((arg) => name.contains(arg))) {
+ runBenchmarkTwoArgs(name, func, files);
+ }
+ }
+
+ benchmark('absolute', context.absolute);
benchmark('basename', context.basename);
benchmark('basenameWithoutExtension', context.basenameWithoutExtension);
benchmark('dirname', context.dirname);
@@ -43,8 +73,14 @@ main(args) {
benchmark('isRootRelative', context.isRootRelative);
benchmark('normalize', context.normalize);
benchmark('relative', context.relative);
+ benchmarkTwoArgs('relative', context.relative);
benchmark('toUri', context.toUri);
benchmark('prettyUri', context.prettyUri);
+ benchmarkTwoArgs('isWithin', context.isWithin);
+ }
+
+ if (args.isEmpty || args.any((arg) => arg == 'current')) {
+ runBenchmark('current', (_) => path.current, [null]);
}
}
« no previous file with comments | « packages/path/CHANGELOG.md ('k') | packages/path/lib/path.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698