A new change detection mechanism was added to AngularDart a few releases ago. I'm trying to write a simple benchmark to compare the new algorithm with the one that was used before.
This is what I came up with:
class User {
String firstName;
String lastName;
User(this.firstName, this.lastName);
}
class Benchmark extends BenchmarkBase {
TestBed tb;
Scope s;
Benchmark(this.tb) : super("Benchmark");
void warmup() {
times(20, (_){ tb.rootScope.apply(); });
}
void exercise() {
times(20, (_){ tb.rootScope.apply(); });
}
setup() {
s = tb.rootScope.createChild({});
times(10000, (i) {
final user = new User("First ${i}", "Last ${i}");
s.context["user${i}"] = user;
s.watch("user${i}.firstName", noop);
});
}
}
I ran this test for Angular 0.9.10 and a similar test for Angular 0.9.4. Surprisingly, Angular 0.9.4 was a bit faster. Is my benchmark too naive?