Skip to content

Commit

Permalink
benchmark: allow compare via fine-grained filters
Browse files Browse the repository at this point in the history
Before this commit, only benchmark targets defined in Makefile could
be used. This commit allows execution of common.js directly and
passing of filter arguments directly, allowing you to run either a
subset of benchmarks or a single specific benchmark for comparison.

PR-URL: #711
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Jeremiah Senkpiel <[email protected]>
  • Loading branch information
mscdex authored and cjihrig committed Feb 4, 2015
1 parent 96ffcb9 commit e0730ee
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions benchmark/compare.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
var usage = 'node benchmark/compare.js ' +
'<node-binary1> <node-binary2> ' +
'[--html] [--red|-r] [--green|-g]';
'[--html] [--red|-r] [--green|-g] ' +
'[-- <type> [testFilter]]';

var show = 'both';
var nodes = [];
var html = false;
var benchmarks;

for (var i = 2; i < process.argv.length; i++) {
var arg = process.argv[i];
Expand All @@ -21,8 +23,15 @@ for (var i = 2; i < process.argv.length; i++) {
case '-h': case '-?': case '--help':
console.log(usage);
process.exit(0);
break;
case '--':
benchmarks = [];
break;
default:
nodes.push(arg);
if (Array.isArray(benchmarks))
benchmarks.push(arg);
else
nodes.push(arg);
break;
}
}
Expand Down Expand Up @@ -65,7 +74,11 @@ function run() {
env.NODE = node;

var out = '';
var child = spawn('make', [runBench], { env: env });
var child;
if (Array.isArray(benchmarks) && benchmarks.length)
child = spawn(node, ['benchmark/common.js'].concat(benchmarks), { env: env });
else
child = spawn('make', [runBench], { env: env });
child.stdout.setEncoding('utf8');
child.stdout.on('data', function(c) {
out += c;
Expand Down

0 comments on commit e0730ee

Please sign in to comment.