Skip to content

Instantly share code, notes, and snippets.

@axemclion
Last active Aug 29, 2015
Embed
What would you like to do?
SVG Scroll tests
/*
Collects runtime rendering metrics for animated spinners from http://codepen.io/axemclion/debug/myZQWE?
Instructions to run tests:
1. Download Chromedriver from https://sites.google.com/a/chromium.org/chromedriver/ and start it
2. Do npm install browser-perf
3. Run this file
*/
var browserPerf = require('browser-perf');
var fs = require('fs');
var MAX_SPINNERS = 8;
var BASE_URL = 'http://codepen.io/axemclion/debug/myZQWE?';
var BROWSERS = {
'desktopChrome': 'chrome'
};
var TEST_BROWSER = 'desktopChrome';
var SELENIUM = 'http://localhost:9515';
function saveResults(device, num, res) {
var data = {};
var fileName = device + '.json';
if (!fs.existsSync(fileName)) {
fs.writeFileSync(fileName, '{}');
}
try {
data = JSON.parse(fs.readFileSync(fileName));
} catch (e) {}
if (typeof data[num] === 'undefined') {
data[num] = {};
}
for (var key in res) {
if (typeof data[num][key] === 'undefined') {
data[num][key] = [];
}
data[num][key].push(res[key]);
}
fs.writeFileSync(fileName, JSON.stringify(data));
}
(function runTest(spinnerCount) {
if (spinnerCount <= MAX_SPINNERS) {
browserPerf(BASE_URL + spinnerCount, function(err, res) {
if (!err) {
saveResults(TEST_BROWSER, spinnerCount, res[0]);
}
runTest(spinnerCount + 1);
}, {
actions: [browserPerf.actions.scroll({
scrollElement: "document.getElementsByTagName('ion-content')[0]"
})],
browserName: [BROWSERS[TEST_BROWSER]],
selenium: SELENIUM
});
} else {
console.log('All tests done');
}
}(1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment