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

Side by Side 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, 11 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 library scope_perf;
2
3 import '_perf.dart';
4 import 'package:angular/core/module.dart';
5 import 'package:angular/core/parser/parser_library.dart';
6 import 'package:di/di.dart';
7 import 'package:di/dynamic_injector.dart';
8
9 main() {
10 var scope = new DynamicInjector(
11 modules: [new Module()
12 ..type(Parser, implementedBy: DynamicParser)],
13 allowImplicitInjection:true).get(Scope);
14 var scope2, scope3, scope4, scope5;
15 var fill = (scope) {
16 for(var i = 0; i < 10000; i++) {
17 scope['key_$i'] = i;
18 }
19 return scope;
20 };
21
22 scope = fill(scope);
23 scope2 = fill(scope.$new());
24 scope3 = fill(scope2.$new());
25 scope4 = fill(scope3.$new());
26 scope5 = fill(scope4.$new());
27
28 time('noop', () {});
29
30 time('empty scope \$digest()', () {
31 scope.$digest();
32 });
33
34 scope.a = new A();
35
36 List watchFns = new List.generate(4000, (i) => () => i);
37 time('adding/removing 4000 watchers', () {
38 List watchers = watchFns.map(scope.$watch).toList();
39 watchers.forEach((e) => e());
40 });
41
42 List watchers = watchFns.map(scope.$watch).toList();
43 time('4000 dummy watchers on scope', () => scope.$digest());
44 watchers.forEach((e) => e());
45
46 for(var i = 0; i < 1000; i++ ) {
47 scope.$watch('a.number', () => null);
48 scope.$watch('a.str', () => null);
49 scope.$watch('a.obj', () => null);
50 }
51
52 time('3000 watchers on scope', () => scope.$digest());
53
54 //TODO(misko): build matrics of these
55 time('scope[] 1 deep', () => scope['nenexistant']);
56 time('scope[] 2 deep', () => scope2['nenexistant']);
57 time('scope[] 3 deep', () => scope3['nenexistant']);
58 time('scope[] 4 deep', () => scope4['nenexistant']);
59 time('scope[] 5 deep', () => scope5['nenexistant']);
60 }
61
62 class A {
63 var number = 1;
64 var str = 'abc';
65 var obj = {};
66 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698