benchmark: use let instead of var in timers

PR-URL: https://github.com/nodejs/node/pull/31794
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
This commit is contained in:
Daniele Belardi 2020-02-14 13:13:58 +01:00 committed by Anna Henningsen
parent 13ad05ce4c
commit de877c5781
No known key found for this signature in database
GPG Key ID: A94130F0BFC8EBE9
7 changed files with 14 additions and 16 deletions

View File

@ -31,7 +31,7 @@ function main({ n, type }) {
// setImmediate tail recursion, 0 arguments
function depth(N) {
var n = 0;
let n = 0;
bench.start();
setImmediate(cb);
function cb() {
@ -45,7 +45,7 @@ function depth(N) {
// setImmediate tail recursion, 1 argument
function depth1(N) {
var n = 0;
let n = 0;
bench.start();
setImmediate(cb, 1);
function cb(a1) {
@ -59,7 +59,7 @@ function depth1(N) {
// Concurrent setImmediate, 0 arguments
function breadth(N) {
var n = 0;
let n = 0;
bench.start();
function cb() {
n++;
@ -73,7 +73,7 @@ function breadth(N) {
// Concurrent setImmediate, 1 argument
function breadth1(N) {
var n = 0;
let n = 0;
bench.start();
function cb(a1) {
n++;
@ -88,7 +88,7 @@ function breadth1(N) {
// Concurrent setImmediate, 4 arguments
function breadth4(N) {
N /= 2;
var n = 0;
let n = 0;
bench.start();
function cb(a1, a2, a3, a4) {
n++;

View File

@ -6,7 +6,7 @@ const bench = common.createBenchmark(main, {
});
function main({ n }) {
var j = 0;
let j = 0;
function cb1(arg1) {
j++;
if (j === n)

View File

@ -6,7 +6,7 @@ const bench = common.createBenchmark(main, {
});
function main({ n }) {
var j = 0;
let j = 0;
bench.start();
function cb() {
j++;

View File

@ -8,11 +8,11 @@ const bench = common.createBenchmark(main, {
function main({ n }) {
var timer = setTimeout(() => {}, 1);
let timer = setTimeout(() => {}, 1);
for (let i = 0; i < n; i++) {
setTimeout(cb, 1);
}
var next = timer._idlePrev;
let next = timer._idlePrev;
clearTimeout(timer);
bench.start();

View File

@ -14,14 +14,13 @@ function main({ n, direction }) {
timersList.push(setTimeout(cb, i + 1));
}
var j;
bench.start();
if (direction === 'start') {
for (j = 0; j < n; j++) {
for (let j = 0; j < n; j++) {
clearTimeout(timersList[j]);
}
} else {
for (j = n - 1; j >= 0; j--) {
for (let j = n - 1; j >= 0; j--) {
clearTimeout(timersList[j]);
}
}

View File

@ -6,7 +6,7 @@ const bench = common.createBenchmark(main, {
});
function main({ n }) {
var i = 0;
let i = 0;
bench.start();
setTimeout(cb, 1);
function cb() {

View File

@ -10,14 +10,13 @@ const bench = common.createBenchmark(main, {
function main({ direction, n }) {
const timersList = [];
var i;
bench.start();
if (direction === 'start') {
for (i = 1; i <= n; i++) {
for (let i = 1; i <= n; i++) {
timersList.push(setTimeout(cb, i));
}
} else {
for (i = n; i > 0; i--) {
for (let i = n; i > 0; i--) {
timersList.push(setTimeout(cb, i));
}
}