Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 289e4ce

Browse filesBrowse files
apapirovskiMylesBorins
authored andcommitted
benchmark: fix next-tick-depth
A recent change made these benchmarks fail by always finishing with 0 iterations. Restore a counter variable. PR-URL: #20461 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent 7a769eb commit 289e4ce
Copy full SHA for 289e4ce

File tree

Expand file treeCollapse file tree

2 files changed

+19
-18
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+19
-18
lines changed
Open diff view settings
Collapse file

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

Copy file name to clipboardExpand all lines: benchmark/process/next-tick-depth-args.js
+17-16Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,52 +8,53 @@ const bench = common.createBenchmark(main, {
88
process.maxTickDepth = Infinity;
99

1010
function main({ n }) {
11+
let counter = n;
1112
function cb4(arg1, arg2, arg3, arg4) {
12-
if (--n) {
13-
if (n % 4 === 0)
13+
if (--counter) {
14+
if (counter % 4 === 0)
1415
process.nextTick(cb4, 3.14, 1024, true, false);
15-
else if (n % 3 === 0)
16+
else if (counter % 3 === 0)
1617
process.nextTick(cb3, 512, true, null);
17-
else if (n % 2 === 0)
18+
else if (counter % 2 === 0)
1819
process.nextTick(cb2, false, 5.1);
1920
else
2021
process.nextTick(cb1, 0);
2122
} else
2223
bench.end(n);
2324
}
2425
function cb3(arg1, arg2, arg3) {
25-
if (--n) {
26-
if (n % 4 === 0)
26+
if (--counter) {
27+
if (counter % 4 === 0)
2728
process.nextTick(cb4, 3.14, 1024, true, false);
28-
else if (n % 3 === 0)
29+
else if (counter % 3 === 0)
2930
process.nextTick(cb3, 512, true, null);
30-
else if (n % 2 === 0)
31+
else if (counter % 2 === 0)
3132
process.nextTick(cb2, false, 5.1);
3233
else
3334
process.nextTick(cb1, 0);
3435
} else
3536
bench.end(n);
3637
}
3738
function cb2(arg1, arg2) {
38-
if (--n) {
39-
if (n % 4 === 0)
39+
if (--counter) {
40+
if (counter % 4 === 0)
4041
process.nextTick(cb4, 3.14, 1024, true, false);
41-
else if (n % 3 === 0)
42+
else if (counter % 3 === 0)
4243
process.nextTick(cb3, 512, true, null);
43-
else if (n % 2 === 0)
44+
else if (counter % 2 === 0)
4445
process.nextTick(cb2, false, 5.1);
4546
else
4647
process.nextTick(cb1, 0);
4748
} else
4849
bench.end(n);
4950
}
5051
function cb1(arg1) {
51-
if (--n) {
52-
if (n % 4 === 0)
52+
if (--counter) {
53+
if (counter % 4 === 0)
5354
process.nextTick(cb4, 3.14, 1024, true, false);
54-
else if (n % 3 === 0)
55+
else if (counter % 3 === 0)
5556
process.nextTick(cb3, 512, true, null);
56-
else if (n % 2 === 0)
57+
else if (counter % 2 === 0)
5758
process.nextTick(cb2, false, 5.1);
5859
else
5960
process.nextTick(cb1, 0);
Collapse file

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

Copy file name to clipboardExpand all lines: benchmark/process/next-tick-depth.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ const bench = common.createBenchmark(main, {
77
process.maxTickDepth = Infinity;
88

99
function main({ n }) {
10-
10+
let counter = n;
1111
bench.start();
1212
process.nextTick(onNextTick);
1313
function onNextTick() {
14-
if (--n)
14+
if (--counter)
1515
process.nextTick(onNextTick);
1616
else
1717
bench.end(n);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.