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

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

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

Powered by Google App Engine
This is Rietveld 408576698