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

Side by Side Diff: packages/polymer_expressions/benchmark/eval.dart

Issue 2312183003: Removed Polymer from Observatory deps (Closed)
Patch Set: Created 4 years, 3 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
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 class EvalBenchmark extends BenchmarkBase {
22 final expr;
23 final scope;
24
25 EvalBenchmark(String name, String expr, {Object model, Map variables})
26 : expr = parse(expr),
27 scope = new Scope(model: model, variables: variables),
28 super('$name: $expr ');
29
30 run() {
31 var value = eval(expr, scope);
32 }
33
34 }
35
36 double total = 0.0;
37
38 benchmark(String name, String expr, {Object model, Map variables}) {
39 var score = new EvalBenchmark(name, expr, model: model, variables: variables)
40 .measure();
41 print("$name $expr: $score us");
42 total += score;
43 }
44
45 main() {
46
47 benchmark('Constant', '1');
48 benchmark('Top-level Name', 'foo',
49 variables: {'foo': new Foo(new Bar('hello'))});
50 benchmark('Model field', 'bar',
51 model: new Foo(new Bar('hello')));
52 benchmark('Path', 'foo.bar.baz',
53 variables: {'foo': new Foo(new Bar('hello'))});
54 benchmark('Map', 'm["foo"]',
55 variables: {'m': {'foo': 1}});
56 benchmark('Equality', '"abc" == "123"');
57 print('total: $total us');
58
59 }
OLDNEW
« no previous file with comments | « packages/polymer_expressions/benchmark/all.dart ('k') | packages/polymer_expressions/benchmark/parse.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698