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

Side by Side Diff: packages/observe/benchmark/observable_list_benchmark.dart

Issue 2989763002: Update charted to 0.4.8 and roll (Closed)
Patch Set: Removed Cutch from list of reviewers Created 3 years, 4 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 library observe.test.benchmark.observable_list_benchmark;
5
6 import 'package:observe/observe.dart';
7 import 'observation_benchmark_base.dart';
8
9 class ObservableListBenchmark extends ObservationBenchmarkBase {
10 final int elementCount = 100;
11
12 ObservableListBenchmark(int objectCount, int mutationCount, String config)
13 : super('ObservableListBenchmark:$objectCount:$mutationCount:$config',
14 objectCount, mutationCount, config);
15
16 @override
17 int mutateObject(ObservableList obj) {
18 switch (config) {
19 case 'update':
20 var size = (elementCount / 10).floor();
21 for (var j = 0; j < size; j++) {
22 obj[j * size]++;
23 }
24 return size;
25
26 case 'splice':
27 var size = (elementCount / 5).floor();
28 // No splice equivalent in List, so we hardcode it.
29 var removed = obj.sublist(size, size * 2);
30 obj.removeRange(size, size * 2);
31 obj.insertAll(size * 2, removed);
32 return size * 2;
33
34 case 'push/pop':
35 var val = obj.removeLast();
36 obj.add(val + 1);
37 return 2;
38
39 case 'shift/unshift':
40 var val = obj.removeAt(0);
41 obj.insert(0, val + 1);
42 return 2;
43
44 default:
45 throw new ArgumentError(
46 'Invalid config for ObservableListBenchmark: $config');
47 }
48 }
49
50 @override
51 ObservableList newObject() {
52 var list = new ObservableList();
53 for (int i = 0; i < elementCount; i++) {
54 list.add(i);
55 }
56 return list;
57 }
58 }
OLDNEW
« no previous file with comments | « packages/observe/benchmark/object_benchmark.dart ('k') | packages/observe/benchmark/observation_benchmark_base.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698