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

Side by Side Diff: third_party/pkg/angular/perf/mirror_perf.dart

Issue 257423008: Update all Angular libs (run update_all.sh). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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 angular.perf.mirror;
2
3 import '_perf.dart';
4 import 'dart:mirrors';
5 import 'package:angular/change_detection/dirty_checking_change_detector.dart';
6
7 main() {
8 var c = new _Obj(1);
9 InstanceMirror im = reflect(c);
10 Symbol symbol = const Symbol('a');
11 _Watch head = new _Watch();
12 _Watch current = head;
13 GetterCache getterCache = new GetterCache({});
14 var detector = new DirtyCheckingChangeDetector<String>(getterCache);
15 for(var i=1; i < 10000; i++) {
16 _Watch next = new _Watch();
17 current = (current.next = new _Watch());
18 detector.watch(c, 'a', '');
19 }
20
21 var dirtyCheck = () {
22 _Watch current = head;
23 while(current != null) {
24 if (!identical(current.lastValue, current.im.getField(current.symbol).refl ectee)) {
25 throw "We should not get here";
26 }
27 current = current.next;
28 }
29 };
30
31 var dirtyCheckFn = () {
32 _Watch current = head;
33 while(current != null) {
34 if (!identical(current.lastValue, current.getter(current.object))) {
35 throw "We should not get here";
36 }
37 current = current.next;
38 }
39 };
40
41 xtime('fieldRead', () => im.getField(symbol).reflectee );
42 xtime('Object.observe', dirtyCheck);
43 xtime('Object.observe fn()', dirtyCheckFn);
44 time('ChangeDetection', detector.collectChanges);
45 }
46
47 class _Watch {
48 dynamic lastValue = 1;
49 _Watch next;
50 String location;
51 dynamic object = new _Obj(1);
52 InstanceMirror im;
53 Symbol symbol = const Symbol('a');
54 Function getter = (s) => s.a;
55
56 _Watch() {
57 im = reflect(object);
58 }
59 }
60
61 class _Obj {
62 var a;
63
64 _Obj(this.a);
65 }
OLDNEW
« no previous file with comments | « third_party/pkg/angular/perf/invoke_perf.dart ('k') | third_party/pkg/angular/perf/parser_perf.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698