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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2013, 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 library polymer_expressions.benchmark.eval;
6
7 import 'package:benchmark_harness/benchmark_harness.dart';
8 import 'package:polymer_expressions/parser.dart' show parse;
9 import 'package:polymer_expressions/eval.dart' show eval, Scope;
10
11 class Foo {
12 final Bar bar;
13 Foo(this.bar);
14 }
15
16 class Bar {
17 String baz;
18 Bar(this.baz);
19 }
20
21 /**
22 * Measures eval time of several expressions. Parsing time is not included.
23 */
24 class PolymerEvalBenchmark extends BenchmarkBase {
25 PolymerEvalBenchmark() : super('PolymerEvalBenchmark');
26
27 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
28 final expr2 = parse('(1 + 2) * 3');
29 final scope = new Scope(variables: {'foo': new Foo(new Bar('hello'))});
30
31 run() {
32 var value = eval(expr, scope);
33 if (value != 'hello') throw new StateError(value);
34 value = eval(expr2, scope);
35 if (value != 9) throw new StateError(value);
36 }
37 }
38
39 main() {
40 new PolymerEvalBenchmark().report();
41 }
OLDNEW
« 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