bench: move next-tick to misc/next-tick-breadth

This commit is contained in:
isaacs
2013-02-11 22:54:27 -08:00
parent f7a4ccb409
commit 7e5cd08061
2 changed files with 21 additions and 17 deletions

View File

@@ -0,0 +1,21 @@
var common = require('../common.js');
var bench = common.createBenchmark(main, {
millions: [2]
});
function main(conf) {
var N = +conf.millions * 1e6;
var n = 0;
function cb() {
n++;
if (n === N)
bench.end(n / 1e6);
}
bench.start();
for (var i = 0; i < N; i++) {
process.nextTick(cb);
}
}

View File

@@ -1,17 +0,0 @@
// run with `time node benchmark/next-tick.js`
var assert = require('assert');
var N = 1e7;
var n = 0;
process.on('exit', function() {
assert.equal(n, N);
});
function cb() {
n++;
}
for (var i = 0; i < N; ++i) {
process.nextTick(cb);
}