Skip to content

Commit f172014

Browse files
dnlupaddaleax
authored andcommitted
benchmark: use let instead of var in timers
PR-URL: #31794 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
1 parent 4ce6fc5 commit f172014

7 files changed

+14
-16
lines changed

benchmark/timers/immediate.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function main({ n, type }) {
3131

3232
// setImmediate tail recursion, 0 arguments
3333
function depth(N) {
34-
var n = 0;
34+
let n = 0;
3535
bench.start();
3636
setImmediate(cb);
3737
function cb() {
@@ -45,7 +45,7 @@ function depth(N) {
4545

4646
// setImmediate tail recursion, 1 argument
4747
function depth1(N) {
48-
var n = 0;
48+
let n = 0;
4949
bench.start();
5050
setImmediate(cb, 1);
5151
function cb(a1) {
@@ -59,7 +59,7 @@ function depth1(N) {
5959

6060
// Concurrent setImmediate, 0 arguments
6161
function breadth(N) {
62-
var n = 0;
62+
let n = 0;
6363
bench.start();
6464
function cb() {
6565
n++;
@@ -73,7 +73,7 @@ function breadth(N) {
7373

7474
// Concurrent setImmediate, 1 argument
7575
function breadth1(N) {
76-
var n = 0;
76+
let n = 0;
7777
bench.start();
7878
function cb(a1) {
7979
n++;
@@ -88,7 +88,7 @@ function breadth1(N) {
8888
// Concurrent setImmediate, 4 arguments
8989
function breadth4(N) {
9090
N /= 2;
91-
var n = 0;
91+
let n = 0;
9292
bench.start();
9393
function cb(a1, a2, a3, a4) {
9494
n++;

benchmark/timers/timers-breadth-args.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const bench = common.createBenchmark(main, {
66
});
77

88
function main({ n }) {
9-
var j = 0;
9+
let j = 0;
1010
function cb1(arg1) {
1111
j++;
1212
if (j === n)

benchmark/timers/timers-breadth.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const bench = common.createBenchmark(main, {
66
});
77

88
function main({ n }) {
9-
var j = 0;
9+
let j = 0;
1010
bench.start();
1111
function cb() {
1212
j++;

benchmark/timers/timers-cancel-pooled.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ const bench = common.createBenchmark(main, {
88

99
function main({ n }) {
1010

11-
var timer = setTimeout(() => {}, 1);
11+
let timer = setTimeout(() => {}, 1);
1212
for (let i = 0; i < n; i++) {
1313
setTimeout(cb, 1);
1414
}
15-
var next = timer._idlePrev;
15+
let next = timer._idlePrev;
1616
clearTimeout(timer);
1717

1818
bench.start();

benchmark/timers/timers-cancel-unpooled.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,13 @@ function main({ n, direction }) {
1414
timersList.push(setTimeout(cb, i + 1));
1515
}
1616

17-
var j;
1817
bench.start();
1918
if (direction === 'start') {
20-
for (j = 0; j < n; j++) {
19+
for (let j = 0; j < n; j++) {
2120
clearTimeout(timersList[j]);
2221
}
2322
} else {
24-
for (j = n - 1; j >= 0; j--) {
23+
for (let j = n - 1; j >= 0; j--) {
2524
clearTimeout(timersList[j]);
2625
}
2726
}

benchmark/timers/timers-depth.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const bench = common.createBenchmark(main, {
66
});
77

88
function main({ n }) {
9-
var i = 0;
9+
let i = 0;
1010
bench.start();
1111
setTimeout(cb, 1);
1212
function cb() {

benchmark/timers/timers-insert-unpooled.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,13 @@ const bench = common.createBenchmark(main, {
1010
function main({ direction, n }) {
1111
const timersList = [];
1212

13-
var i;
1413
bench.start();
1514
if (direction === 'start') {
16-
for (i = 1; i <= n; i++) {
15+
for (let i = 1; i <= n; i++) {
1716
timersList.push(setTimeout(cb, i));
1817
}
1918
} else {
20-
for (i = n; i > 0; i--) {
19+
for (let i = n; i > 0; i--) {
2120
timersList.push(setTimeout(cb, i));
2221
}
2322
}

0 commit comments

Comments
 (0)