• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3const common = require('../common.js');
4const bench = common.createBenchmark(main, {
5  n: [1e7]
6});
7
8function main({ n }) {
9  let j = 0;
10
11  function cb1(arg1) {
12    j++;
13    if (j === n)
14      bench.end(n);
15  }
16
17  function cb2(arg1, arg2) {
18    j++;
19    if (j === n)
20      bench.end(n);
21  }
22
23  function cb3(arg1, arg2, arg3) {
24    j++;
25    if (j === n)
26      bench.end(n);
27  }
28
29  function cb4(arg1, arg2, arg3, arg4) {
30    j++;
31    if (j === n)
32      bench.end(n);
33  }
34
35  bench.start();
36  for (let i = 0; i < n; i++) {
37    if (i % 4 === 0)
38      process.nextTick(cb4, 3.14, 1024, true, false);
39    else if (i % 3 === 0)
40      process.nextTick(cb3, 512, true, null);
41    else if (i % 2 === 0)
42      process.nextTick(cb2, false, 5.1);
43    else
44      process.nextTick(cb1, 0);
45  }
46}
47