mirror of
https://github.com/zebrajr/node.git
synced 2025-12-06 12:20:27 +01:00
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:
parent
13ad05ce4c
commit
de877c5781
|
|
@ -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++;
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ const bench = common.createBenchmark(main, {
|
|||
});
|
||||
|
||||
function main({ n }) {
|
||||
var j = 0;
|
||||
let j = 0;
|
||||
bench.start();
|
||||
function cb() {
|
||||
j++;
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user