diff options
Diffstat (limited to 'benchmark/misc/set-immediate-depth.js')
-rw-r--r-- | benchmark/misc/set-immediate-depth.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/benchmark/misc/set-immediate-depth.js b/benchmark/misc/set-immediate-depth.js new file mode 100644 index 0000000000..12b9cdc7e6 --- /dev/null +++ b/benchmark/misc/set-immediate-depth.js @@ -0,0 +1,22 @@ +'use strict'; + +const common = require('../common.js'); +const bench = common.createBenchmark(main, { + millions: [10] +}); + +function main(conf) { + const N = +conf.millions * 1e6; + let n = N; + + process.on('exit', function() { + bench.end(N / 1e6); + }); + + bench.start(); + setImmediate(onNextTick); + function onNextTick() { + if (--n) + setImmediate(onNextTick); + } +} |