From 8c273e40d7e637aa116bb5a1e9c818c9ddbe64e4 Mon Sep 17 00:00:00 2001 From: Joshua Wise Date: Tue, 11 Apr 2017 20:38:56 -0400 Subject: [PATCH] improved benchmark filtering --- benchmark/index.js | 24 ++++++++++++------------ benchmark/trials.js | 9 ++++++++- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/benchmark/index.js b/benchmark/index.js index 0de6bacb..5b17d592 100644 --- a/benchmark/index.js +++ b/benchmark/index.js @@ -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); } } @@ -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)')); diff --git a/benchmark/trials.js b/benchmark/trials.js index 35156b59..a48d123a 100644 --- a/benchmark/trials.js +++ b/benchmark/trials.js @@ -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)) {