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

Unified Diff: third_party/pkg/angular/perf/scope_perf.dart

Issue 124053002: Adding Angular and dependent packages for testing (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 12 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: third_party/pkg/angular/perf/scope_perf.dart
diff --git a/third_party/pkg/angular/perf/scope_perf.dart b/third_party/pkg/angular/perf/scope_perf.dart
new file mode 100644
index 0000000000000000000000000000000000000000..888060d10adb6b37d8ad8b13a12c0edef94bc91b
--- /dev/null
+++ b/third_party/pkg/angular/perf/scope_perf.dart
@@ -0,0 +1,66 @@
+library scope_perf;
+
+import '_perf.dart';
+import 'package:angular/core/module.dart';
+import 'package:angular/core/parser/parser_library.dart';
+import 'package:di/di.dart';
+import 'package:di/dynamic_injector.dart';
+
+main() {
+ var scope = new DynamicInjector(
+ modules: [new Module()
+ ..type(Parser, implementedBy: DynamicParser)],
+ allowImplicitInjection:true).get(Scope);
+ var scope2, scope3, scope4, scope5;
+ var fill = (scope) {
+ for(var i = 0; i < 10000; i++) {
+ scope['key_$i'] = i;
+ }
+ return scope;
+ };
+
+ scope = fill(scope);
+ scope2 = fill(scope.$new());
+ scope3 = fill(scope2.$new());
+ scope4 = fill(scope3.$new());
+ scope5 = fill(scope4.$new());
+
+ time('noop', () {});
+
+ time('empty scope \$digest()', () {
+ scope.$digest();
+ });
+
+ scope.a = new A();
+
+ List watchFns = new List.generate(4000, (i) => () => i);
+ time('adding/removing 4000 watchers', () {
+ List watchers = watchFns.map(scope.$watch).toList();
+ watchers.forEach((e) => e());
+ });
+
+ List watchers = watchFns.map(scope.$watch).toList();
+ time('4000 dummy watchers on scope', () => scope.$digest());
+ watchers.forEach((e) => e());
+
+ for(var i = 0; i < 1000; i++ ) {
+ scope.$watch('a.number', () => null);
+ scope.$watch('a.str', () => null);
+ scope.$watch('a.obj', () => null);
+ }
+
+ time('3000 watchers on scope', () => scope.$digest());
+
+ //TODO(misko): build matrics of these
+ time('scope[] 1 deep', () => scope['nenexistant']);
+ time('scope[] 2 deep', () => scope2['nenexistant']);
+ time('scope[] 3 deep', () => scope3['nenexistant']);
+ time('scope[] 4 deep', () => scope4['nenexistant']);
+ time('scope[] 5 deep', () => scope5['nenexistant']);
+}
+
+class A {
+ var number = 1;
+ var str = 'abc';
+ var obj = {};
+}

Powered by Google App Engine
This is Rietveld 408576698