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

Unified Diff: packages/observe/benchmark/setup_observation_benchmark_base.dart

Issue 2989763002: Update charted to 0.4.8 and roll (Closed)
Patch Set: Removed Cutch from list of reviewers Created 3 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: packages/observe/benchmark/setup_observation_benchmark_base.dart
diff --git a/packages/observe/benchmark/setup_observation_benchmark_base.dart b/packages/observe/benchmark/setup_observation_benchmark_base.dart
deleted file mode 100644
index ef1545c63dab1612d4ceec444efe6b0db407db9e..0000000000000000000000000000000000000000
--- a/packages/observe/benchmark/setup_observation_benchmark_base.dart
+++ /dev/null
@@ -1,74 +0,0 @@
-// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-library observe.test.benchmark.setup_observation_benchmark_base;
-
-import 'dart:async';
-import 'dart:html';
-import 'package:observe/observe.dart';
-import 'package:benchmark_harness/benchmark_harness.dart';
-
-abstract class SetupObservationBenchmarkBase extends BenchmarkBase {
- /// The number of objects to create and observe.
- final int objectCount;
-
- /// The current configuration.
- final String config;
-
- /// The objects we want to observe.
- List<Observable> objects;
-
- SetupObservationBenchmarkBase(String name, this.objectCount, this.config)
- : super(name);
-
- /// Subclasses should use this method to return an observable object to be
- /// benchmarked.
- Observable newObject();
-
- /// Subclasses should override this to do anything other than a default change
- /// listener. It must return either a StreamSubscription or a PathObserver.
- newObserver(obj) => obj.changes.listen((_) {});
-
- /// Set up each benchmark by creating all the objects.
- @override
- void setup() {
- objects = [];
- while (objects.length < objectCount) {
- objects.add(newObject());
- }
- }
-
- /// Tear down each the benchmark and remove all listeners.
- @override
- void teardown() {
- while (objects.isNotEmpty) {
- var obj = objects.removeLast();
- if (obj.hasObservers || (obj is ObservableList && obj.hasListObservers)) {
- window.alert('Observers leaked!');
- }
- }
- objects = null;
- }
-
- /// Run the benchmark by creating a listener on each object.
- @override
- void run() {
- for (var object in objects) {
- var observer = newObserver(object);
-
- // **Note:** This is different than the JS implementation. Since run can
- // be called an arbitrary number of times between [setup] and [teardown],
- // we clean up all observers as we go. This means we are measuring both
- // the setup and teardown of observers, versus the setup only in the
- // JS benchmark. Not cleaning these up ends up giving `oh snap` errors.
- if (observer is StreamSubscription) {
- observer.cancel();
- } else if (observer is PathObserver) {
- observer.close();
- } else {
- throw 'Unknown observer type ${observer.runtimeType}. Only '
- '[PathObserver] and [StreamSubscription] are supported.';
- }
- }
- }
-}
« no previous file with comments | « packages/observe/benchmark/setup_observable_list_benchmark.dart ('k') | packages/observe/benchmark/setup_path_benchmark.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698