Browse Source

bench: compare binaries equal times

The benchmark compare would drop the last run of the binary pairs. So
when they were only run once an error would arise because no data was
generated for the second binary.
v0.10.1-release
Trevor Norris 12 years ago
committed by Ben Noordhuis
parent
commit
31314b6978
  1. 24
      benchmark/compare.js

24
benchmark/compare.js

@ -48,36 +48,24 @@ if (nodes.length !== 2)
var spawn = require('child_process').spawn; var spawn = require('child_process').spawn;
var results = {}; var results = {};
var n = 1; var toggle = 1;
var r = (+process.env.NODE_BENCH_RUNS || 1) * 2;
run(); run();
var RUNS = +process.env.NODE_BENCH_RUNS || 1;
var r = RUNS;
function run() { function run() {
// Flip back and forth between the two binaries. if (--r < 0)
if (n === 1) {
n--;
} else {
r--;
if (r === 0)
return compare(); return compare();
else toggle = ++toggle % 2;
n++;
}
if (n === -1) var node = nodes[toggle];
return compare();
var node = nodes[n];
console.error('running %s', node); console.error('running %s', node);
var env = {}; var env = {};
for (var i in process.env) for (var i in process.env)
env[i] = process.env[i]; env[i] = process.env[i];
env.NODE = node; env.NODE = node;
var child = spawn('make', [runBench], { env: env });
var out = ''; var out = '';
var child = spawn('make', [runBench], { env: env });
child.stdout.setEncoding('utf8'); child.stdout.setEncoding('utf8');
child.stdout.on('data', function(c) { child.stdout.on('data', function(c) {
out += c; out += c;

Loading…
Cancel
Save