2015-10-13 03:29:13 -04:00
|
|
|
import {runClickBenchmark, verifyNoBrowserErrors} from 'angular2/src/testing/perf_util';
|
2015-05-30 00:40:15 -04:00
|
|
|
|
|
|
|
describe('ng2 di benchmark', function() {
|
|
|
|
|
|
|
|
var URL = 'benchmarks/src/di/di_benchmark.html';
|
|
|
|
|
2015-05-30 11:17:27 -04:00
|
|
|
afterEach(verifyNoBrowserErrors);
|
2015-05-30 00:40:15 -04:00
|
|
|
|
|
|
|
it('should log the stats for getByToken', function(done) {
|
2015-05-30 11:17:27 -04:00
|
|
|
runClickBenchmark({
|
|
|
|
url: URL,
|
|
|
|
buttons: ['#getByToken'],
|
|
|
|
id: 'ng2.di.getByToken',
|
|
|
|
params: [{name: 'iterations', value: 20000, scale: 'linear'}],
|
2015-08-27 11:44:59 -04:00
|
|
|
microMetrics: {'injectAvg': 'avg time for injection (in ms)'},
|
|
|
|
waitForAngular2: false
|
2015-05-30 11:17:27 -04:00
|
|
|
}).then(done, done.fail);
|
2015-05-30 00:40:15 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should log the stats for getByKey', function(done) {
|
2015-05-30 11:17:27 -04:00
|
|
|
runClickBenchmark({
|
|
|
|
url: URL,
|
|
|
|
buttons: ['#getByKey'],
|
|
|
|
id: 'ng2.di.getByKey',
|
|
|
|
params: [{name: 'iterations', value: 20000, scale: 'linear'}],
|
2015-08-27 11:44:59 -04:00
|
|
|
microMetrics: {'injectAvg': 'avg time for injection (in ms)'},
|
|
|
|
waitForAngular2: false
|
2015-05-30 11:17:27 -04:00
|
|
|
}).then(done, done.fail);
|
2015-05-30 00:40:15 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should log the stats for getChild', function(done) {
|
2015-05-30 11:17:27 -04:00
|
|
|
runClickBenchmark({
|
|
|
|
url: URL,
|
|
|
|
buttons: ['#getChild'],
|
|
|
|
id: 'ng2.di.getChild',
|
|
|
|
params: [{name: 'iterations', value: 20000, scale: 'linear'}],
|
2015-08-27 11:44:59 -04:00
|
|
|
microMetrics: {'injectAvg': 'avg time for getChild (in ms)'},
|
|
|
|
waitForAngular2: false
|
2015-05-30 11:17:27 -04:00
|
|
|
}).then(done, done.fail);
|
2015-05-30 00:40:15 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should log the stats for instantiate', function(done) {
|
2015-05-30 11:17:27 -04:00
|
|
|
runClickBenchmark({
|
|
|
|
url: URL,
|
|
|
|
buttons: ['#instantiate'],
|
|
|
|
id: 'ng2.di.instantiate',
|
|
|
|
params: [{name: 'iterations', value: 10000, scale: 'linear'}],
|
2015-08-27 11:44:59 -04:00
|
|
|
microMetrics: {'injectAvg': 'avg time for instantiate (in ms)'},
|
|
|
|
waitForAngular2: false
|
2015-05-30 11:17:27 -04:00
|
|
|
}).then(done, done.fail);
|
2015-05-30 00:40:15 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This benchmark measures the cost of creating a new injector with a mix
|
|
|
|
* of binding types: Type, unresolved, unflattened.
|
|
|
|
*/
|
|
|
|
it('should log the stats for createVariety', function(done) {
|
2015-05-30 11:17:27 -04:00
|
|
|
runClickBenchmark({
|
|
|
|
url: URL,
|
|
|
|
buttons: ['#createVariety'],
|
|
|
|
id: 'ng2.di.createVariety',
|
|
|
|
params: [{name: 'iterations', value: 10000, scale: 'linear'}],
|
2015-08-27 11:44:59 -04:00
|
|
|
microMetrics: {'injectAvg': 'avg time for createVariety (in ms)'},
|
|
|
|
waitForAngular2: false
|
2015-05-30 11:17:27 -04:00
|
|
|
}).then(done, done.fail);
|
2015-05-30 00:40:15 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Same as 'createVariety' benchmark but operates on fully resolved bindings.
|
|
|
|
*/
|
|
|
|
it('should log the stats for createVarietyResolved', function(done) {
|
2015-05-30 11:17:27 -04:00
|
|
|
runClickBenchmark({
|
|
|
|
url: URL,
|
|
|
|
buttons: ['#createVarietyResolved'],
|
|
|
|
id: 'ng2.di.createVarietyResolved',
|
|
|
|
params: [{name: 'iterations', value: 10000, scale: 'linear'}],
|
2015-08-27 11:44:59 -04:00
|
|
|
microMetrics: {'injectAvg': 'avg time for createVarietyResolved (in ms)'},
|
|
|
|
waitForAngular2: false
|
2015-05-30 11:17:27 -04:00
|
|
|
}).then(done, done.fail);
|
2015-05-30 00:40:15 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
});
|