Skip to content

Commit 97c4394

Browse files
committed
benchmark: cover more nextTick() code
The benchmarks for `process.nextTick()` do not cover the `default` case in the internal code's `switch` statement where the callback receives more than 3 arguments. Modify two of the benchmarks to include this condition. PR-URL: #14645 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Refael Ackermann <[email protected]>
1 parent a253704 commit 97c4394

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

benchmark/process/next-tick-breadth-args.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,17 @@ function main(conf) {
2424
if (n === N)
2525
bench.end(n / 1e6);
2626
}
27+
function cb4(arg1, arg2, arg3, arg4) {
28+
n++;
29+
if (n === N)
30+
bench.end(n / 1e6);
31+
}
2732

2833
bench.start();
2934
for (var i = 0; i < N; i++) {
30-
if (i % 3 === 0)
35+
if (i % 4 === 0)
36+
process.nextTick(cb4, 3.14, 1024, true, false);
37+
else if (i % 3 === 0)
3138
process.nextTick(cb3, 512, true, null);
3239
else if (i % 2 === 0)
3340
process.nextTick(cb2, false, 5.1);

benchmark/process/next-tick-depth-args.js

+22-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,24 @@ process.maxTickDepth = Infinity;
1010
function main(conf) {
1111
var n = +conf.millions * 1e6;
1212

13+
function cb4(arg1, arg2, arg3, arg4) {
14+
if (--n) {
15+
if (n % 4 === 0)
16+
process.nextTick(cb4, 3.14, 1024, true, false);
17+
else if (n % 3 === 0)
18+
process.nextTick(cb3, 512, true, null);
19+
else if (n % 2 === 0)
20+
process.nextTick(cb2, false, 5.1);
21+
else
22+
process.nextTick(cb1, 0);
23+
} else
24+
bench.end(+conf.millions);
25+
}
1326
function cb3(arg1, arg2, arg3) {
1427
if (--n) {
15-
if (n % 3 === 0)
28+
if (n % 4 === 0)
29+
process.nextTick(cb4, 3.14, 1024, true, false);
30+
else if (n % 3 === 0)
1631
process.nextTick(cb3, 512, true, null);
1732
else if (n % 2 === 0)
1833
process.nextTick(cb2, false, 5.1);
@@ -23,7 +38,9 @@ function main(conf) {
2338
}
2439
function cb2(arg1, arg2) {
2540
if (--n) {
26-
if (n % 3 === 0)
41+
if (n % 4 === 0)
42+
process.nextTick(cb4, 3.14, 1024, true, false);
43+
else if (n % 3 === 0)
2744
process.nextTick(cb3, 512, true, null);
2845
else if (n % 2 === 0)
2946
process.nextTick(cb2, false, 5.1);
@@ -34,7 +51,9 @@ function main(conf) {
3451
}
3552
function cb1(arg1) {
3653
if (--n) {
37-
if (n % 3 === 0)
54+
if (n % 4 === 0)
55+
process.nextTick(cb4, 3.14, 1024, true, false);
56+
else if (n % 3 === 0)
3857
process.nextTick(cb3, 512, true, null);
3958
else if (n % 2 === 0)
4059
process.nextTick(cb2, false, 5.1);

0 commit comments

Comments
 (0)