benchmark/index.js
function benchBatch(targets, cb, idx) {
  idx |= 0;
  if (targets.length == 0) return cb(idx);

  var target = targets.shift();
  process.stdout.write(util.format('[%s] ', idx+1));
  try {
    main.bench(target.name, target.func);
    idx++;
  } catch (err) {
    console.log('%s failed!', target.name);
  }

  //No more targets, no need to wait
  if (targets.length == 0) return cb(idx);

  //We need to wait some seconds before the next test,
  //or the results could vary depending on the order
  setTimeout(function() {
    benchBatch(targets, cb, idx); //Yeah, recursivity...
  }, 10000);
}
function benchBatch(targets, cb, idx) {
  idx |= 0;
  if (targets.length == 0) return cb(idx);

  var target = targets.shift();
  process.stdout.write(util.format('[%s] ', idx+1));
  try {
    main.bench(target.name, target.func);
    idx++;
  } catch (err) {
    console.log('%s failed!', target.name);
  }

  //No more targets, no need to wait
  if (targets.length == 0) return cb(idx);

  //We need to wait some seconds before the next test,
  //or the results could vary depending on the order
  setTimeout(function() {
    benchBatch(targets, cb, idx); //Yeah, recursivity...
  }, 10000);
}
function benchBatch ( targets , cb , idx ) { idx |= 0 ; if ( targets . length == 0 ) return cb ( idx ) ; var target = targets . shift ( ) ; process . stdout . write ( util . format ( '[%s] ' , idx + 1 ) ) ; try { main . bench ( target . name , target . func ) ; idx ++ ; } catch ( err ) { console . log ( '%s failed!' , target . name ) ; } //No more targets, no need to wait if ( targets . length == 0 ) return cb ( idx ) ; //We need to wait some seconds before the next test, //or the results could vary depending on the order setTimeout ( function ( ) { benchBatch ( targets , cb , idx ) ; //Yeah, recursivity... } , 10000 ) ; }
Benchmark a series of target functions
Benchmark a series of target functions