• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2const common = require('../common.js');
3const bench = common.createBenchmark(main, {
4  n: [1e4, 2e4, 4e4],
5  loop: [1e2, 2e2],
6});
7
8function main({ n, loop }) {
9  bench.start();
10  run();
11  function run() {
12    let j = 0;
13
14    function cb() {
15      j++;
16      if (j === n) {
17        loop--;
18        if (loop === 0) {
19          bench.end(n);
20        } else {
21          run();
22        }
23      }
24    }
25
26    for (let i = 0; i < n; i++) {
27      if (i % 4 === 0)
28        process.nextTick(cb, i, true, 10, 'test');
29      else if (i % 3 === 0)
30        process.nextTick(cb, i, true, 10);
31      else if (i % 2 === 0)
32        process.nextTick(cb, i, 20);
33      else
34        process.nextTick(cb, i);
35    }
36  }
37}
38