Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 } | |
| OLD | NEW |