summaryrefslogtreecommitdiff
path: root/benchmark/process/next-tick-breadth.js
blob: 8f8d0adc618dadf21dde9e46168b257dbbc80b2c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
'use strict';

const common = require('../common.js');
const bench = common.createBenchmark(main, {
  millions: [2]
});

function main(conf) {
  const 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);
  }
}