2015-01-09 21:00:04 -05:00
|
|
|
var benchpress = require('../../../tools/benchpress/index.js');
|
|
|
|
var webdriver = require('protractor/node_modules/selenium-webdriver');
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
runClickBenchmark: runClickBenchmark,
|
|
|
|
verifyNoBrowserErrors: benchpress.verifyNoBrowserErrors
|
|
|
|
};
|
|
|
|
|
|
|
|
function runClickBenchmark(config) {
|
2015-01-15 18:14:54 -05:00
|
|
|
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);
|
|
|
|
});
|
|
|
|
benchpress.runBenchmark(benchmarkConfig, function() {
|
|
|
|
buttons.forEach(function(button) {
|
|
|
|
button.click();
|
|
|
|
});
|
|
|
|
});
|
2015-01-09 21:00:04 -05:00
|
|
|
});
|
2015-01-15 18:14:54 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2015-01-09 21:00:04 -05:00
|
|
|
});
|
2015-01-15 18:14:54 -05:00
|
|
|
return scaleFactor;
|
2015-01-09 21:00:04 -05:00
|
|
|
});
|
2015-01-15 18:14:54 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2015-01-09 21:00:04 -05:00
|
|
|
}
|