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

Unified 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, 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/mirror_perf.dart
diff --git a/third_party/pkg/angular/perf/mirror_perf.dart b/third_party/pkg/angular/perf/mirror_perf.dart
new file mode 100644
index 0000000000000000000000000000000000000000..70b22a80883d78b93f9c205d96de2f478902e228
--- /dev/null
+++ b/third_party/pkg/angular/perf/mirror_perf.dart
@@ -0,0 +1,60 @@
+library angular.perf.mirror;
+
+import '_perf.dart';
+import 'dart:mirrors';
+
+main() {
+ var c = new Obj(1);
+ InstanceMirror im = reflect(c);
+ Symbol symbol = new Symbol('a');
+ Watch head = new Watch();
+ Watch current = head;
+ for(var i=1; i < 10000; i++) {
+ Watch next = new Watch();
+ current = (current.next = new Watch());
+ }
+
+ var dirtyCheck = () {
+ Watch current = head;
+ while(current != null) {
+ if (!identical(current.lastValue, current.im.getField(current.symbol).reflectee)) {
+ throw "We should not get here";
+ }
+ current = current.next;
+ }
+ };
+
+ var dirtyCheckFn = () {
+ Watch current = head;
+ while(current != null) {
+ if (!identical(current.lastValue, current.getter(current.object))) {
+ throw "We should not get here";
+ }
+ current = current.next;
+ }
+ };
+
+ time('fieldRead', () => im.getField(symbol).reflectee );
+ time('Object.observe', dirtyCheck);
+ time('Object.observe fn()', dirtyCheckFn);
+}
+
+class Watch {
+ dynamic lastValue = 1;
+ Watch next;
+ String location;
+ dynamic object = new Obj(1);
+ InstanceMirror im;
+ Symbol symbol = new Symbol('a');
+ Function getter = (s) => s.a;
+
+ Watch() {
+ im = reflect(object);
+ }
+}
+
+class Obj {
+ var a;
+
+ Obj(this.a);
+}

Powered by Google App Engine
This is Rietveld 408576698