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

Unified Diff: pkg/polymer_expressions/benchmark/eval.dart

Issue 73523004: Initial polymer_expressions benchmarks (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/polymer_expressions/benchmark/all.dart ('k') | pkg/polymer_expressions/benchmark/parse.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/polymer_expressions/benchmark/eval.dart
diff --git a/pkg/polymer_expressions/benchmark/eval.dart b/pkg/polymer_expressions/benchmark/eval.dart
new file mode 100644
index 0000000000000000000000000000000000000000..aad2cfbc2a719e331f88f02a7a8f66a434fe40b3
--- /dev/null
+++ b/pkg/polymer_expressions/benchmark/eval.dart
@@ -0,0 +1,41 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library polymer_expressions.benchmark.eval;
+
+import 'package:benchmark_harness/benchmark_harness.dart';
+import 'package:polymer_expressions/parser.dart' show parse;
+import 'package:polymer_expressions/eval.dart' show eval, Scope;
+
+class Foo {
+ final Bar bar;
+ Foo(this.bar);
+}
+
+class Bar {
+ String baz;
+ Bar(this.baz);
+}
+
+/**
+ * Measures eval time of several expressions. Parsing time is not included.
+ */
+class PolymerEvalBenchmark extends BenchmarkBase {
+ PolymerEvalBenchmark() : super('PolymerEvalBenchmark');
+
+ final expr = parse('foo.bar.baz');
Jennifer Messerly 2013/11/15 22:32:58 just a rough sense based on what I've seen in code
+ final expr2 = parse('(1 + 2) * 3');
+ final scope = new Scope(variables: {'foo': new Foo(new Bar('hello'))});
+
+ run() {
+ var value = eval(expr, scope);
+ if (value != 'hello') throw new StateError(value);
+ value = eval(expr2, scope);
+ if (value != 9) throw new StateError(value);
+ }
+}
+
+main() {
+ new PolymerEvalBenchmark().report();
+}
« no previous file with comments | « pkg/polymer_expressions/benchmark/all.dart ('k') | pkg/polymer_expressions/benchmark/parse.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698