Skip to content

Instantly share code, notes, and snippets.

@trueadm
Forked from axemclion/index.js
Last active August 29, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trueadm/93697f88b26e11fa462f to your computer and use it in GitHub Desktop.
Save trueadm/93697f88b26e11fa462f to your computer and use it in GitHub Desktop.
var urls = {
react: 'http://run.plnkr.co/plunks/Wwgjjpl9NHMO5Nd1TUyN/',
ember: 'https://dbmonster.firebaseapp.com/',
underscore: 'http://jashkenas.github.io/dbmonster/',
ractive: 'http://www.rich-harris.co.uk/ractive-dbmonster/',
paperclip: 'http://paperclip-dbmonster.herokuapp.com/',
t7_cito: 'http://t7js.com/dbmonster/',
t7_cito_precompiled: 'http://t7js.com/dbmonster/precompiled.html'
}
var browserPerf = require('browser-perf');
var FILE = 'data.json';
var fs = require('fs');
if (!fs.existsSync(FILE)) {
fs.writeFileSync(FILE, JSON.stringify({}));
}
var frameworks = Object.keys(urls);
(function runTest(i) {
if (i >= frameworks.length) {
console.log('All tests done');
return;
}
repeatTest(frameworks[i], function() {
runTest(i + 1);
});
}(0));
function repeatTest(framework, cb) {
var REPEAT = 10;
console.log('Running test for %s', framework);
(function iterate(i) {
if (i >= REPEAT) {
console.log('All tests done for %s', framework);
cb();
return;
}
console.log('[%d|%d]', i, REPEAT);
browserPerf(urls[framework], function(err, result) {
if (err) {
console.error(err);
} else {
var data = JSON.parse(fs.readFileSync(FILE));
if (typeof data[framework] === 'undefined') {
data[framework] = {};
}
result.forEach(function(res) {
for (var metric in res) {
if (typeof data[framework][metric] === 'undefined') {
data[framework][metric] = [];
}
data[framework][metric].push(res[metric]);
}
});
fs.writeFileSync(FILE, JSON.stringify(data));
}
iterate(i + 1);
}, {
selenium: 'http://localhost:9515',
browsers: ['chrome']
});
}(0));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment