refactor(perf): use webdriver to execute benchmarks

- use performance log of chromedriver / appium to get timeline data
  for calculating metrics for benchmarks
- change all benchmarks to be made of a standalone application
  and a protractor test that collectes timeline data
- fix and simplify benchmarks
- add dart2js to build
- remove benchpress

Closes #330
This commit is contained in:
Tobias Bosch
2014-12-22 17:50:10 -08:00
parent d642c6afb5
commit df4ac0dd33
66 changed files with 1146 additions and 985 deletions

View File

@ -0,0 +1,10 @@
<!doctype html>
<html>
<body>
<button id="instantiate">ElementInjector.instantiate</button>
<button id="instantiateDirectives">ElementInjector.instantiateDirectives</button>
$SCRIPTS$
</body>
</html>

View File

@ -0,0 +1,69 @@
import {reflector} from 'reflection/reflection';
import {Injector} from 'di/di';
import {ProtoElementInjector} from 'core/compiler/element_injector';
import {document, DOM} from 'facade/dom';
var count = 0;
var ITERATIONS = 20000;
function setupReflector() {
reflector.registerType(A, {
'factory': () => new A(),
'parameters': [],
'annotations' : []
});
reflector.registerType(B, {
'factory': () => new B(),
'parameters': [],
'annotations' : []
});
reflector.registerType(C, {
'factory': (a,b) => new C(a,b),
'parameters': [[A],[B]],
'annotations' : []
});
}
export function main() {
setupReflector();
var appInjector = new Injector([]);
var bindings = [A, B, C];
var proto = new ProtoElementInjector(null, 0, bindings);
var elementInjector = proto.instantiate(null,null);
function instantiate (_) {
for (var i = 0; i < ITERATIONS; ++i) {
var ei = proto.instantiate(null, null);
ei.instantiateDirectives(appInjector, null, null);
}
}
function instantiateDirectives (_) {
for (var i = 0; i < ITERATIONS; ++i) {
elementInjector.clearDirectives();
elementInjector.instantiateDirectives(appInjector, null, null);
}
}
DOM.on(DOM.querySelector(document, '#instantiate'), 'click', instantiate);
DOM.on(DOM.querySelector(document, '#instantiateDirectives'), 'click', instantiateDirectives);
}
class A {
constructor() {
count++;
}
}
class B {
constructor() {
count++;
}
}
class C {
constructor(a:A, b:B) {
count++;
}
}

View File

@ -1,34 +0,0 @@
import {Injector} from 'di/di';
import {ProtoElementInjector} from 'core/compiler/element_injector';
var ITERATIONS = 20000;
var count = 0;
export function run () {
var appInjector = new Injector([]);
var bindings = [A, B, C];
var proto = new ProtoElementInjector(null, 0, bindings);
for (var i = 0; i < ITERATIONS; ++i) {
var ei = proto.instantiate(null, null);
ei.instantiateDirectives(appInjector, null, null);
}
}
class A {
constructor() {
count++;
}
}
class B {
constructor() {
count++;
}
}
class C {
constructor(a:A, b:B) {
count++;
}
}

View File

@ -1,42 +0,0 @@
import {Binding, Dependency, Key, Injector} from 'di/di';
import {ProtoElementInjector} from 'core/compiler/element_injector';
var ITERATIONS = 20000;
var count = 0;
export function run () {
var appInjector = new Injector([]);
var bindings = [
new Binding(Key.get(A), () => new A(), [], false),
new Binding(Key.get(B), () => new B(), [], false),
new Binding(Key.get(C), (a,b) => new C(a,b), [
new Dependency(Key.get(A), false, false, []),
new Dependency(Key.get(B), false, false, [])
], false)];
var proto = new ProtoElementInjector(null, 0, bindings);
for (var i = 0; i < ITERATIONS; ++i) {
var ei = proto.instantiate(null,null);
ei.instantiateDirectives(appInjector, null, null);
}
}
class A {
constructor() {
count++;
}
}
class B {
constructor() {
count++;
}
}
class C {
constructor(a:A, b:B) {
count++;
}
}

View File

@ -1,36 +0,0 @@
import {Injector} from 'di/di';
import {ProtoElementInjector} from 'core/compiler/element_injector';
var ITERATIONS = 20000;
var count = 0;
export function run () {
var appInjector = new Injector([]);
var bindings = [A, B, C];
var proto = new ProtoElementInjector(null, 0, bindings);
var ei = proto.instantiate(null,null);
for (var i = 0; i < ITERATIONS; ++i) {
ei.clearDirectives();
ei.instantiateDirectives(appInjector, null, null);
}
}
class A {
constructor() {
count++;
}
}
class B {
constructor() {
count++;
}
}
class C {
constructor(a:A, b:B) {
count++;
}
}

View File

@ -1 +0,0 @@
$SCRIPTS$

View File

@ -1,19 +0,0 @@
import * as instantiate_benchmark from './instantiate_benchmark';
import * as instantiate_directive_benchmark from './instantiate_directive_benchmark';
import * as instantiate_benchmark_codegen from './instantiate_benchmark_codegen';
import {benchmark, benchmarkStep} from 'benchpress/benchpress';
export function main() {
benchmark(`ElementInjector.instantiate + instantiateDirectives`, function() {
benchmarkStep('run', instantiate_benchmark.run);
});
benchmark(`ElementInjector.instantiateDirectives`, function() {
benchmarkStep('run', instantiate_directive_benchmark.run);
});
benchmark(`ElementInjector.instantiate + instantiateDirectives (codegen)`, function() {
benchmarkStep('run', instantiate_benchmark_codegen.run);
});
}