Skip to content

Commit e0730ee

Browse files
mscdexcjihrig
authored andcommitted
benchmark: allow compare via fine-grained filters
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]>
1 parent 96ffcb9 commit e0730ee

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

benchmark/compare.js

+16-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
var usage = 'node benchmark/compare.js ' +
22
'<node-binary1> <node-binary2> ' +
3-
'[--html] [--red|-r] [--green|-g]';
3+
'[--html] [--red|-r] [--green|-g] ' +
4+
'[-- <type> [testFilter]]';
45

56
var show = 'both';
67
var nodes = [];
78
var html = false;
9+
var benchmarks;
810

911
for (var i = 2; i < process.argv.length; i++) {
1012
var arg = process.argv[i];
@@ -21,8 +23,15 @@ for (var i = 2; i < process.argv.length; i++) {
2123
case '-h': case '-?': case '--help':
2224
console.log(usage);
2325
process.exit(0);
26+
break;
27+
case '--':
28+
benchmarks = [];
29+
break;
2430
default:
25-
nodes.push(arg);
31+
if (Array.isArray(benchmarks))
32+
benchmarks.push(arg);
33+
else
34+
nodes.push(arg);
2635
break;
2736
}
2837
}
@@ -65,7 +74,11 @@ function run() {
6574
env.NODE = node;
6675

6776
var out = '';
68-
var child = spawn('make', [runBench], { env: env });
77+
var child;
78+
if (Array.isArray(benchmarks) && benchmarks.length)
79+
child = spawn(node, ['benchmark/common.js'].concat(benchmarks), { env: env });
80+
else
81+
child = spawn('make', [runBench], { env: env });
6982
child.stdout.setEncoding('utf8');
7083
child.stdout.on('data', function(c) {
7184
out += c;

0 commit comments

Comments
 (0)