summaryrefslogtreecommitdiff
path: root/benchmark/process/next-tick-depth.js
blob: e11beb4d0b1f31a42187122475e15ba406b2808d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
'use strict';
const common = require('../common.js');
const bench = common.createBenchmark(main, {
  millions: [12]
});

process.maxTickDepth = Infinity;

function main(conf) {
  var n = +conf.millions * 1e6;

  bench.start();
  process.nextTick(onNextTick);
  function onNextTick() {
    if (--n)
      process.nextTick(onNextTick);
    else
      bench.end(+conf.millions);
  }
}