Skip to content

Instantly share code, notes, and snippets.

@vsavkin
Created October 28, 2014 17:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vsavkin/e57f04d29cfbe07131c8 to your computer and use it in GitHub Desktop.
Save vsavkin/e57f04d29cfbe07131c8 to your computer and use it in GitHub Desktop.
angulardart1.0 benchmark
library angular.benchmark.directive_injector;
import 'package:angular/angular.dart';
import 'package:angular/application_factory.dart';
import 'package:angular/mock/module.dart';
import 'package:benchmark_harness/benchmark_harness.dart';
import 'dart:html';
import 'dart:js' as js;
var count = 0;
class A {
A() {
count++;
}
}
class B {
B() {
count++;
}
}
class C {
C(A a, B b) {
count++;
}
}
void main() {
var A_KEY = new Key(A);
var B_KEY = new Key(B);
var C_KEY = new Key(C);
var A_FACTORY = () => new A();
var B_FACTORY = () => new B();
var C_FACTORY = (a,b) => new C(a,b);
var DEPS = [A_KEY, B_KEY];
createDirectives(_) {
for (var i = 0; i < 20000; ++i) {
var dirInjector = new DirectiveInjector(null, null, null, null, null, null, null);
dirInjector.bindByKey(A_KEY, A_FACTORY, []);
dirInjector.bindByKey(B_KEY, B_FACTORY, []);
dirInjector.bindByKey(C_KEY, C_FACTORY, DEPS);
dirInjector.get(A);
dirInjector.get(B);
dirInjector.get(C);
}
}
js.context['benchmarkSteps'].add(new js.JsObject.jsify({
"name": "DirectiveInjector", "fn": new js.JsFunction.withThis(createDirectives)
}));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment