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 library observe.test.benchmark.path_benchmark; | |
5 | |
6 import 'package:observe/observe.dart'; | |
7 import 'observation_benchmark_base.dart'; | |
8 import 'test_path_observable.dart'; | |
9 | |
10 class PathBenchmark extends ObservationBenchmarkBase { | |
11 final PropertyPath path = new PropertyPath('foo.bar.baz'); | |
12 | |
13 PathBenchmark(int objectCount, int mutationCount, String config) : super( | |
14 'PathBenchmark:$objectCount:$mutationCount:$config', objectCount, | |
15 mutationCount, config); | |
16 | |
17 @override | |
18 int mutateObject(TestPathObservable obj) { | |
19 switch (config) { | |
20 case 'leaf': | |
21 obj.foo.bar.baz += 1; | |
22 // Make sure [obj.foo.bar] delivers its changes synchronously. The base | |
23 // class already handles this for [obj]. | |
24 obj.foo.bar.deliverChanges(); | |
25 return 1; | |
26 | |
27 case 'root': | |
28 obj.foo = new Foo(obj.foo.bar.baz + 1); | |
29 return 1; | |
30 | |
31 default: | |
32 throw new ArgumentError('Invalid config for PathBenchmark: $config'); | |
33 } | |
34 } | |
35 | |
36 @override | |
37 TestPathObservable newObject() => new TestPathObservable(1); | |
38 | |
39 @override | |
40 PathObserver newObserver(TestPathObservable obj) => | |
41 new PathObserver(obj, path)..open((_) => mutations--); | |
42 } | |
OLD | NEW |