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

Side by Side Diff: third_party/pkg/angular/perf/mirror_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 angular.perf.mirror;
2
3 import '_perf.dart';
4 import 'dart:mirrors';
5
6 main() {
7 var c = new Obj(1);
8 InstanceMirror im = reflect(c);
9 Symbol symbol = new Symbol('a');
10 Watch head = new Watch();
11 Watch current = head;
12 for(var i=1; i < 10000; i++) {
13 Watch next = new Watch();
14 current = (current.next = new Watch());
15 }
16
17 var dirtyCheck = () {
18 Watch current = head;
19 while(current != null) {
20 if (!identical(current.lastValue, current.im.getField(current.symbol).refl ectee)) {
21 throw "We should not get here";
22 }
23 current = current.next;
24 }
25 };
26
27 var dirtyCheckFn = () {
28 Watch current = head;
29 while(current != null) {
30 if (!identical(current.lastValue, current.getter(current.object))) {
31 throw "We should not get here";
32 }
33 current = current.next;
34 }
35 };
36
37 time('fieldRead', () => im.getField(symbol).reflectee );
38 time('Object.observe', dirtyCheck);
39 time('Object.observe fn()', dirtyCheckFn);
40 }
41
42 class Watch {
43 dynamic lastValue = 1;
44 Watch next;
45 String location;
46 dynamic object = new Obj(1);
47 InstanceMirror im;
48 Symbol symbol = new Symbol('a');
49 Function getter = (s) => s.a;
50
51 Watch() {
52 im = reflect(object);
53 }
54 }
55
56 class Obj {
57 var a;
58
59 Obj(this.a);
60 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698