feat(ElementInjector): implement ElementInjector
This commit is contained in:
10
modules/benchmarks/pubspec.yaml
Normal file
10
modules/benchmarks/pubspec.yaml
Normal file
@ -0,0 +1,10 @@
|
||||
name: bnehcmarks
|
||||
environment:
|
||||
sdk: '>=1.4.0'
|
||||
dependencies:
|
||||
facade:
|
||||
path: ../facade
|
||||
di:
|
||||
path: ../di
|
||||
core:
|
||||
path: ../core
|
11
modules/benchmarks/src/di/benchmark.dart
Normal file
11
modules/benchmarks/src/di/benchmark.dart
Normal file
@ -0,0 +1,11 @@
|
||||
library injector_get_benchmark;
|
||||
|
||||
import './injector_instantiate_benchmark.dart' as b;
|
||||
import 'dart:js' as js;
|
||||
|
||||
main () {
|
||||
js.context['benchmarkSteps'].add(new js.JsObject.jsify({
|
||||
"name": "Injector.instantiate",
|
||||
"fn": new js.JsFunction.withThis((_) => b.run())
|
||||
}));
|
||||
}
|
@ -10,8 +10,6 @@ export function run () {
|
||||
var child = injector.createChild([E]);
|
||||
child.get(E);
|
||||
}
|
||||
|
||||
console.log(count)
|
||||
}
|
||||
|
||||
class A {
|
||||
|
11
modules/benchmarks/src/element_injector/benchmark.dart
Normal file
11
modules/benchmarks/src/element_injector/benchmark.dart
Normal file
@ -0,0 +1,11 @@
|
||||
library element_injector_benchmark;
|
||||
|
||||
import './instantiate_benchmark.dart' as ib;
|
||||
import 'dart:js' as js;
|
||||
|
||||
main () {
|
||||
js.context['benchmarkSteps'].add(new js.JsObject.jsify({
|
||||
"name": "ElementInjector.instantiate + instantiateDirectives",
|
||||
"fn": new js.JsFunction.withThis((_) => ib.run())
|
||||
}));
|
||||
}
|
7
modules/benchmarks/src/element_injector/benchmark.es5
Normal file
7
modules/benchmarks/src/element_injector/benchmark.es5
Normal file
@ -0,0 +1,7 @@
|
||||
System.import('benchmarks/element_injector/instantiate_benchmark').then(function (bm) {
|
||||
window.benchmarkSteps.push({name: 'ElementInjector.instantiate + instantiateDirectives', fn: bm.run});
|
||||
}, console.log.bind(console));
|
||||
|
||||
System.import('benchmarks/element_injector/instantiate_directive_benchmark').then(function (bm) {
|
||||
window.benchmarkSteps.push({name: 'ElementInjector.instantiateDirectives', fn: bm.run});
|
||||
}, console.log.bind(console));
|
11
modules/benchmarks/src/element_injector/bp.conf.es5
Normal file
11
modules/benchmarks/src/element_injector/bp.conf.es5
Normal file
@ -0,0 +1,11 @@
|
||||
module.exports = function(config) {
|
||||
config.set({
|
||||
scripts: [
|
||||
{src: '/js/traceur-runtime.js'},
|
||||
{src: '/js/es6-module-loader-sans-promises.src.js'},
|
||||
{src: '/js/extension-register.js'},
|
||||
{src: 'register_system.js'},
|
||||
{src: 'benchmark.js'}
|
||||
]
|
||||
});
|
||||
};
|
@ -0,0 +1,33 @@
|
||||
import {Injector} from 'di/di';
|
||||
import {ProtoElementInjector} from 'core/compiler/element_injector';
|
||||
|
||||
var count = 0;
|
||||
|
||||
export function run () {
|
||||
var appInjector = new Injector([]);
|
||||
|
||||
var bindings = [A, B, C];
|
||||
var proto = new ProtoElementInjector(null, bindings, []);
|
||||
for (var i = 0; i < 20000; ++i) {
|
||||
var ei = proto.instantiate();
|
||||
ei.instantiateDirectives(appInjector);
|
||||
}
|
||||
}
|
||||
|
||||
class A {
|
||||
constructor() {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
class B {
|
||||
constructor() {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
class C {
|
||||
constructor(a:A, b:B) {
|
||||
count++;
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
import {Injector} from 'di/di';
|
||||
import {ProtoElementInjector} from 'core/compiler/element_injector';
|
||||
|
||||
var count = 0;
|
||||
|
||||
export function run () {
|
||||
var appInjector = new Injector([]);
|
||||
|
||||
var bindings = [A, B, C];
|
||||
var proto = new ProtoElementInjector(null, bindings, []);
|
||||
var ei = proto.instantiate();
|
||||
|
||||
for (var i = 0; i < 20000; ++i) {
|
||||
ei.clearDirectives();
|
||||
ei.instantiateDirectives(appInjector);
|
||||
}
|
||||
}
|
||||
|
||||
class A {
|
||||
constructor() {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
class B {
|
||||
constructor() {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
class C {
|
||||
constructor(a:A, b:B) {
|
||||
count++;
|
||||
}
|
||||
}
|
0
modules/benchmarks/src/element_injector/main.html
Normal file
0
modules/benchmarks/src/element_injector/main.html
Normal file
10
modules/benchmarks/src/element_injector/register_system.es5
Normal file
10
modules/benchmarks/src/element_injector/register_system.es5
Normal file
@ -0,0 +1,10 @@
|
||||
System.paths = {
|
||||
'core/*': '/js/core/lib/*.js',
|
||||
'change_detection/*': '/js/change_detection/lib/*.js',
|
||||
'facade/*': '/js/facade/lib/*.js',
|
||||
'di/*': '/js/di/lib/*.js',
|
||||
'rtts_assert/*': '/js/rtts_assert/lib/*.js',
|
||||
'test_lib/*': '/js/test_lib/lib/*.js',
|
||||
'benchmarks/*': '/js/benchmarks/lib/*.js'
|
||||
};
|
||||
register(System);
|
Reference in New Issue
Block a user