bench: add process.nextTick() benchmark
This commit is contained in:
parent
f53d092a2a
commit
5fee1ff7bc
17
benchmark/next-tick.js
Normal file
17
benchmark/next-tick.js
Normal file
@ -0,0 +1,17 @@
|
||||
// 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);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user