feat(perf): autoscale benchmarks depending on the browser.
This commit is contained in:
parent
561ad3a68c
commit
5c064c19e2
|
@ -12,7 +12,7 @@ describe('ng2 change detection benchmark', function () {
|
|||
buttons: ['#ng2DetectChanges'],
|
||||
id: 'ng2.changeDetection',
|
||||
params: [{
|
||||
name: 'iterations', value: 500000
|
||||
name: 'iterations', value: 500000, scale: 'linear'
|
||||
}]
|
||||
});
|
||||
});
|
||||
|
@ -23,7 +23,7 @@ describe('ng2 change detection benchmark', function () {
|
|||
buttons: ['#baselineDetectChanges'],
|
||||
id: 'baseline.changeDetection',
|
||||
params: [{
|
||||
name: 'iterations', value: 500000
|
||||
name: 'iterations', value: 500000, scale: 'linear'
|
||||
}]
|
||||
});
|
||||
});
|
||||
|
|
|
@ -12,7 +12,7 @@ describe('ng2 compiler benchmark', function () {
|
|||
buttons: ['#compileWithBindings'],
|
||||
id: 'ng2.compile.withBindings',
|
||||
params: [{
|
||||
name: 'elementCount', selector: '#elementCount', value: 150
|
||||
name: 'elementCount', selector: '#elementCount', value: 150, scale: 'linear'
|
||||
}]
|
||||
});
|
||||
});
|
||||
|
@ -23,7 +23,7 @@ describe('ng2 compiler benchmark', function () {
|
|||
buttons: ['#compileNoBindings'],
|
||||
id: 'ng2.compile.noBindings',
|
||||
params: [{
|
||||
name: 'elementCount', value: 150
|
||||
name: 'elementCount', value: 150, scale: 'linear'
|
||||
}]
|
||||
});
|
||||
});
|
||||
|
|
|
@ -12,7 +12,7 @@ describe('ng2 di benchmark', function () {
|
|||
buttons: ['#getByToken'],
|
||||
id: 'ng2.di.getByToken',
|
||||
params: [{
|
||||
name: 'iterations', value: 20000
|
||||
name: 'iterations', value: 20000, scale: 'linear'
|
||||
}]
|
||||
});
|
||||
});
|
||||
|
@ -23,7 +23,7 @@ describe('ng2 di benchmark', function () {
|
|||
buttons: ['#getByKey'],
|
||||
id: 'ng2.di.getByKey',
|
||||
params: [{
|
||||
name: 'iterations', value: 20000
|
||||
name: 'iterations', value: 20000, scale: 'linear'
|
||||
}]
|
||||
});
|
||||
});
|
||||
|
@ -34,7 +34,7 @@ describe('ng2 di benchmark', function () {
|
|||
buttons: ['#getChild'],
|
||||
id: 'ng2.di.getChild',
|
||||
params: [{
|
||||
name: 'iterations', value: 20000
|
||||
name: 'iterations', value: 20000, scale: 'linear'
|
||||
}]
|
||||
});
|
||||
});
|
||||
|
@ -45,7 +45,7 @@ describe('ng2 di benchmark', function () {
|
|||
buttons: ['#instantiate'],
|
||||
id: 'ng2.di.instantiate',
|
||||
params: [{
|
||||
name: 'iterations', value: 10000
|
||||
name: 'iterations', value: 10000, scale: 'linear'
|
||||
}]
|
||||
});
|
||||
});
|
||||
|
|
|
@ -12,7 +12,7 @@ describe('ng2 element injector benchmark', function () {
|
|||
buttons: ['#instantiate'],
|
||||
id: 'ng2.elementInjector.instantiate',
|
||||
params: [{
|
||||
name: 'iterations', value: 20000
|
||||
name: 'iterations', value: 20000, scale: 'linear'
|
||||
}]
|
||||
});
|
||||
});
|
||||
|
@ -23,7 +23,7 @@ describe('ng2 element injector benchmark', function () {
|
|||
buttons: ['#instantiateDirectives'],
|
||||
id: 'ng2.elementInjector.instantiateDirectives',
|
||||
params: [{
|
||||
name: 'iterations', value: 20000
|
||||
name: 'iterations', value: 20000, scale: 'linear'
|
||||
}]
|
||||
});
|
||||
});
|
||||
|
|
|
@ -12,7 +12,7 @@ describe('ng2 selector benchmark', function () {
|
|||
buttons: ['#parse'],
|
||||
id: 'ng2.selector.parse',
|
||||
params: [{
|
||||
name: 'selectors', value: 10000
|
||||
name: 'selectors', value: 10000, scale: 'linear'
|
||||
}]
|
||||
});
|
||||
});
|
||||
|
@ -22,7 +22,7 @@ describe('ng2 selector benchmark', function () {
|
|||
buttons: ['#addSelectable'],
|
||||
id: 'ng2.selector.addSelectable',
|
||||
params: [{
|
||||
name: 'selectors', value: 10000
|
||||
name: 'selectors', value: 10000, scale: 'linear'
|
||||
}]
|
||||
});
|
||||
});
|
||||
|
@ -33,7 +33,7 @@ describe('ng2 selector benchmark', function () {
|
|||
buttons: ['#match'],
|
||||
id: 'ng2.selector.match',
|
||||
params: [{
|
||||
name: 'selectors', value: 10000
|
||||
name: 'selectors', value: 10000, scale: 'linear'
|
||||
}]
|
||||
});
|
||||
});
|
||||
|
|
|
@ -12,7 +12,7 @@ describe('ng2 tree benchmark', function () {
|
|||
buttons: ['#ng2DestroyDom', '#ng2CreateDom'],
|
||||
id: 'ng2.tree',
|
||||
params: [{
|
||||
name: 'depth', value: 9
|
||||
name: 'depth', value: 9, scale: 'log2'
|
||||
}]
|
||||
});
|
||||
});
|
||||
|
@ -23,7 +23,7 @@ describe('ng2 tree benchmark', function () {
|
|||
buttons: ['#baselineDestroyDom', '#baselineCreateDom'],
|
||||
id: 'baseline.tree',
|
||||
params: [{
|
||||
name: 'depth', value: 9
|
||||
name: 'depth', value: 9, scale: 'log2'
|
||||
}]
|
||||
});
|
||||
});
|
||||
|
|
|
@ -12,7 +12,7 @@ describe('ng1.x compiler benchmark', function () {
|
|||
buttons: ['#compileWithBindings'],
|
||||
id: 'ng1.compile.withBindings',
|
||||
params: [{
|
||||
name: 'elementCount', value: 150
|
||||
name: 'elementCount', value: 150, scale: 'linear'
|
||||
}]
|
||||
});
|
||||
});
|
||||
|
@ -23,7 +23,7 @@ describe('ng1.x compiler benchmark', function () {
|
|||
buttons: ['#compileNoBindings'],
|
||||
id: 'ng1.compile.noBindings',
|
||||
params: [{
|
||||
name: 'elementCount', value: 150
|
||||
name: 'elementCount', value: 150, scale: 'linear'
|
||||
}]
|
||||
});
|
||||
});
|
||||
|
|
|
@ -24,10 +24,12 @@ describe('ng1.x largetable benchmark', function () {
|
|||
id: 'ng1.largetable.' + benchmarkType,
|
||||
params: [{
|
||||
name: 'columns',
|
||||
value: 100
|
||||
value: 100,
|
||||
scale: 'sqrt'
|
||||
},{
|
||||
name: 'rows',
|
||||
value: 20
|
||||
value: 20,
|
||||
scale: 'sqrt'
|
||||
},{
|
||||
name: 'benchmarkType',
|
||||
value: benchmarkType
|
||||
|
|
|
@ -12,7 +12,7 @@ describe('ng1.x tree benchmark', function () {
|
|||
buttons: ['#destroyDom', '#createDom'],
|
||||
id: 'ng1.tree',
|
||||
params: [{
|
||||
name: 'depth', value: 9
|
||||
name: 'depth', value: 9, scale: 'log2'
|
||||
}]
|
||||
});
|
||||
});
|
||||
|
|
|
@ -7,19 +7,53 @@ module.exports = {
|
|||
};
|
||||
|
||||
function runClickBenchmark(config) {
|
||||
var url = encodeURI(config.url + '?' + config.params.map(function(param) {
|
||||
var globalParams = browser.params;
|
||||
getScaleFactor(globalParams.benchmark.scaling).then(function(scaleFactor) {
|
||||
var params = config.params.map(function(param) {
|
||||
return {
|
||||
name: param.name, value: applyScaleFactor(param.value, scaleFactor, param.scale)
|
||||
}
|
||||
});
|
||||
var benchmarkConfig = Object.create(globalParams.benchmark);
|
||||
benchmarkConfig.id = globalParams.lang+'.'+config.id;
|
||||
benchmarkConfig.params = params;
|
||||
benchmarkConfig.scaleFactor = scaleFactor;
|
||||
|
||||
var url = encodeURI(config.url + '?' + params.map(function(param) {
|
||||
return param.name + '=' + param.value;
|
||||
}).join('&'));
|
||||
browser.get(url);
|
||||
var buttons = config.buttons.map(function(selector) {
|
||||
return $(selector);
|
||||
});
|
||||
var benchmarkConfig = Object.create(browser.params.benchmark);
|
||||
benchmarkConfig.id = browser.params.lang+'.'+config.id;
|
||||
benchmarkConfig.params = config.params;
|
||||
benchpress.runBenchmark(benchmarkConfig, function() {
|
||||
buttons.forEach(function(button) {
|
||||
button.click();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function getScaleFactor(possibleScalings) {
|
||||
return browser.executeScript('return navigator.userAgent').then(function(userAgent) {
|
||||
var scaleFactor = 1;
|
||||
possibleScalings.forEach(function(entry) {
|
||||
if (userAgent.match(entry.userAgent)) {
|
||||
scaleFactor = entry.value;
|
||||
}
|
||||
});
|
||||
return scaleFactor;
|
||||
});
|
||||
}
|
||||
|
||||
function applyScaleFactor(value, scaleFactor, method) {
|
||||
if (method === 'log2') {
|
||||
return value + Math.log2(scaleFactor);
|
||||
} else if (method === 'sqrt') {
|
||||
return value * Math.sqrt(scaleFactor);
|
||||
} else if (method === 'linear') {
|
||||
return value * scaleFactor;
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
}
|
|
@ -27,7 +27,7 @@ config.params = {
|
|||
],
|
||||
cloudReporter: cloudReporterConfig,
|
||||
scaling: [{
|
||||
browserName: /chrome/, value: 0.5
|
||||
userAgent: /Android/, value: 0.125
|
||||
}]
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue