Skip to content

Commit

Permalink
improved benchmark filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaWise committed Apr 12, 2017
1 parent 63b088c commit 8c273e4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
24 changes: 12 additions & 12 deletions benchmark/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,20 @@ var trials;
}());

function getTrials() {
return process.argv.slice(2).reduce(filterByArgs, require('./trials'));
return process.argv.slice(2).reduce(filterByArgs, require('./trials').map(addSearchTerms));

function addSearchTerms(trial) {
var size = trial.table.toLowerCase().indexOf('large') === -1 ? 'small' : 'large';
var columns = trial.columns.join(',').toLowerCase();
trial.terms = [trial.type.toLowerCase(), size, columns];
return trial;
}
function filterByArgs(trials, arg) {
arg = arg.toLowerCase();
return trials.filter(function (obj) {return valuesOf(obj).some(containsThis, arg);});
}
function valuesOf(obj) {
return Object.keys(obj).map(function (key) {return String(this[key]);}, obj).join(',').toLowerCase().split(',');
return trials.filter(function (obj) {return obj.terms.some(matchesThis, arg);});
}
function containsThis(str) {
return str.indexOf(this) !== -1;
function matchesThis(str) {
return str === String(this);
}
}

Expand All @@ -57,12 +60,9 @@ function nextTrial() {
}

var trial = trials.shift();
var type = trial.type;
var size = trial.table.toLowerCase().indexOf('large') === -1 ? 'small' : 'large';
var columns = trial.columns.join(',');
console.log(clc.cyan([type, size, columns].join(' ')));
console.log(clc.cyan(trial.terms.join(' ')));

var child = spawn('node', [path.join(__dirname, 'types', type), JSON.stringify(trial)], {stdio: 'inherit'});
var child = spawn('node', [path.join(__dirname, 'types', trial.type), JSON.stringify(trial)], {stdio: 'inherit'});
child.on('exit', function (code) {
if (code !== 0) {
console.log(clc.red('ERROR (probably out of memory)'));
Expand Down
9 changes: 8 additions & 1 deletion benchmark/trials.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@ module.exports = [
{type: 'select', table: 'allSmall', columns: ['blob']},
{type: 'select', table: 'allSmall', columns: ['nul']},
{type: 'select', table: 'allLarge', columns: ['text']},
{type: 'select', table: 'allLarge', columns: ['blob']}
{type: 'select', table: 'allLarge', columns: ['blob']},
{type: 'select-all', table: 'allSmall', columns: ['integer']},
{type: 'select-all', table: 'allSmall', columns: ['real']},
{type: 'select-all', table: 'allSmall', columns: ['text']},
{type: 'select-all', table: 'allSmall', columns: ['blob']},
{type: 'select-all', table: 'allSmall', columns: ['nul']},
{type: 'select-all', table: 'allLarge', columns: ['text']},
{type: 'select-all', table: 'allLarge', columns: ['blob']}
];

if (/^(1|true|on|yes)$/i.test(process.env.NO_CACHE)) {
Expand Down

0 comments on commit 8c273e4

Please sign in to comment.