feat(di): added hostInjector and viewInjector to the Directive annotation
This commit is contained in:
@ -20,11 +20,11 @@ describe('ng2 element injector benchmark', function () {
|
||||
}).then(done, done.fail);
|
||||
});
|
||||
|
||||
it('should log the stats for instantiateDirectives', function(done) {
|
||||
it('should log the stats for hydrate', function(done) {
|
||||
perfUtil.runClickBenchmark({
|
||||
url: URL,
|
||||
buttons: ['#instantiateDirectives'],
|
||||
id: 'ng2.elementInjector.instantiateDirectives',
|
||||
buttons: ['#hydrate'],
|
||||
id: 'ng2.elementInjector.hydrate',
|
||||
params: [{
|
||||
name: 'iterations', value: 20000, scale: 'linear'
|
||||
}],
|
||||
|
@ -13,7 +13,7 @@
|
||||
<h2>Actions</h2>
|
||||
<p>
|
||||
<button id="instantiate">instantiate</button>
|
||||
<button id="instantiateDirectives">instantiateDirectives</button>
|
||||
<button id="hydrate">hydrate</button>
|
||||
</p>
|
||||
|
||||
$SCRIPTS$
|
||||
|
@ -1,7 +1,7 @@
|
||||
import {reflector} from 'angular2/src/reflection/reflection';
|
||||
import {ReflectionCapabilities} from 'angular2/src/reflection/reflection_capabilities';
|
||||
import {Injectable, Injector} from 'angular2/di';
|
||||
import {ProtoElementInjector} from 'angular2/src/core/compiler/element_injector';
|
||||
import {ProtoElementInjector, DirectiveBinding} from 'angular2/src/core/compiler/element_injector';
|
||||
import {getIntParameter, bindAction, microBenchmark} from 'angular2/src/test_lib/benchmark_util';
|
||||
import {BrowserDomAdapter} from 'angular2/src/dom/browser_adapter';
|
||||
|
||||
@ -14,21 +14,25 @@ export function main() {
|
||||
reflector.reflectionCapabilities = new ReflectionCapabilities();
|
||||
var appInjector = Injector.resolveAndCreate([]);
|
||||
|
||||
var bindings = [A, B, C];
|
||||
var proto = new ProtoElementInjector(null, 0, bindings);
|
||||
var bindings = [
|
||||
DirectiveBinding.createFromType(A, null),
|
||||
DirectiveBinding.createFromType(B, null),
|
||||
DirectiveBinding.createFromType(C, null)
|
||||
];
|
||||
var proto = ProtoElementInjector.create(null, 0, bindings, false, 0);
|
||||
var elementInjector = proto.instantiate(null);
|
||||
|
||||
function instantiate () {
|
||||
for (var i = 0; i < iterations; ++i) {
|
||||
var ei = proto.instantiate(null);
|
||||
ei.instantiateDirectives(appInjector, null, null);
|
||||
ei.hydrate(appInjector, null, null);
|
||||
}
|
||||
}
|
||||
|
||||
function instantiateDirectives () {
|
||||
function hydrate () {
|
||||
for (var i = 0; i < iterations; ++i) {
|
||||
elementInjector.clearDirectives();
|
||||
elementInjector.instantiateDirectives(appInjector, null, null);
|
||||
elementInjector.dehydrate();
|
||||
elementInjector.hydrate(appInjector, null, null);
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,8 +41,8 @@ export function main() {
|
||||
() => microBenchmark('instantiateAvg', iterations, instantiate)
|
||||
);
|
||||
bindAction(
|
||||
'#instantiateDirectives',
|
||||
() => microBenchmark('instantiateAvg', iterations, instantiateDirectives)
|
||||
'#hydrate',
|
||||
() => microBenchmark('instantiateAvg', iterations, hydrate)
|
||||
);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user