Skip to content

Commit

Permalink
benchmark: use let instead of var in timers
Browse files Browse the repository at this point in the history
PR-URL: #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>
  • Loading branch information
dnlup authored and targos committed Apr 28, 2020
1 parent 33858fa commit f3ef894
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 16 deletions.
10 changes: 5 additions & 5 deletions benchmark/timers/immediate.js
Expand Up @@ -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() {
Expand All @@ -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) {
Expand All @@ -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++;
Expand All @@ -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++;
Expand All @@ -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++;
Expand Down
2 changes: 1 addition & 1 deletion benchmark/timers/timers-breadth-args.js
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion benchmark/timers/timers-breadth.js
Expand Up @@ -6,7 +6,7 @@ const bench = common.createBenchmark(main, {
});

function main({ n }) {
var j = 0;
let j = 0;
bench.start();
function cb() {
j++;
Expand Down
4 changes: 2 additions & 2 deletions benchmark/timers/timers-cancel-pooled.js
Expand Up @@ -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();
Expand Down
5 changes: 2 additions & 3 deletions benchmark/timers/timers-cancel-unpooled.js
Expand Up @@ -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]);
}
}
Expand Down
2 changes: 1 addition & 1 deletion benchmark/timers/timers-depth.js
Expand Up @@ -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() {
Expand Down
5 changes: 2 additions & 3 deletions benchmark/timers/timers-insert-unpooled.js
Expand Up @@ -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));
}
}
Expand Down

0 comments on commit f3ef894

Please sign in to comment.