Skip to content

Commit

Permalink
benchmark: swap var for let in benchmarks
Browse files Browse the repository at this point in the history
In benchmark directory this changes for loops
using var to let when it applies for consistency

PR-URL: nodejs#28958
Reviewed-By: Anna Henningsen <anna@addaleax.net>
  • Loading branch information
RamirezAlex authored and addaleax committed Feb 13, 2020
1 parent 9e805b1 commit d0ed431
Show file tree
Hide file tree
Showing 47 changed files with 51 additions and 51 deletions.
2 changes: 1 addition & 1 deletion benchmark/module/module-loader-deep.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function main({ ext, cache, files }) {
`${benchmarkDirectory}/a.js`,
'module.exports = {};'
);
for (var i = 0; i <= files; i++) {
for (let i = 0; i <= files; i++) {
fs.mkdirSync(`${benchmarkDirectory}/${i}`);
fs.writeFileSync(
`${benchmarkDirectory}/${i}/package.json`,
Expand Down
2 changes: 1 addition & 1 deletion benchmark/module/module-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const bench = common.createBenchmark(main, {
function main({ n, name, cache, files, dir }) {
tmpdir.refresh();
fs.mkdirSync(benchmarkDirectory);
for (var i = 0; i <= files; i++) {
for (let i = 0; i <= files; i++) {
fs.mkdirSync(`${benchmarkDirectory}${i}`);
fs.writeFileSync(
`${benchmarkDirectory}${i}/package.json`,
Expand Down
2 changes: 1 addition & 1 deletion benchmark/os/cpus.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const bench = common.createBenchmark(main, {

function main({ n }) {
bench.start();
for (var i = 0; i < n; ++i)
for (let i = 0; i < n; ++i)
cpus();
bench.end(n);
}
2 changes: 1 addition & 1 deletion benchmark/os/loadavg.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const bench = common.createBenchmark(main, {

function main({ n }) {
bench.start();
for (var i = 0; i < n; ++i)
for (let i = 0; i < n; ++i)
loadavg();
bench.end(n);
}
2 changes: 1 addition & 1 deletion benchmark/os/networkInterfaces.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const bench = common.createBenchmark(main, {

function main({ n }) {
bench.start();
for (var i = 0; i < n; ++i)
for (let i = 0; i < n; ++i)
networkInterfaces();
bench.end(n);
}
2 changes: 1 addition & 1 deletion benchmark/path/basename-posix.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function main({ n, pathext }) {
}

bench.start();
for (var i = 0; i < n; i++) {
for (let i = 0; i < n; i++) {
posix.basename(i % 3 === 0 ? `${pathext}${i}` : pathext, ext);
}
bench.end(n);
Expand Down
2 changes: 1 addition & 1 deletion benchmark/path/basename-win32.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function main({ n, pathext }) {
}

bench.start();
for (var i = 0; i < n; i++) {
for (let i = 0; i < n; i++) {
win32.basename(i % 3 === 0 ? `${pathext}${i}` : pathext, ext);
}
bench.end(n);
Expand Down
2 changes: 1 addition & 1 deletion benchmark/path/dirname-posix.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const bench = common.createBenchmark(main, {

function main({ n, path }) {
bench.start();
for (var i = 0; i < n; i++) {
for (let i = 0; i < n; i++) {
posix.dirname(i % 3 === 0 ? `${path}${i}` : path);
}
bench.end(n);
Expand Down
2 changes: 1 addition & 1 deletion benchmark/path/dirname-win32.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const bench = common.createBenchmark(main, {

function main({ n, path }) {
bench.start();
for (var i = 0; i < n; i++) {
for (let i = 0; i < n; i++) {
win32.dirname(i % 3 === 0 ? `${path}${i}` : path);
}
bench.end(n);
Expand Down
2 changes: 1 addition & 1 deletion benchmark/path/extname-posix.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const bench = common.createBenchmark(main, {

function main({ n, path }) {
bench.start();
for (var i = 0; i < n; i++) {
for (let i = 0; i < n; i++) {
posix.extname(i % 3 === 0 ? `${path}${i}` : path);
}
bench.end(n);
Expand Down
2 changes: 1 addition & 1 deletion benchmark/path/extname-win32.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const bench = common.createBenchmark(main, {

function main({ n, path }) {
bench.start();
for (var i = 0; i < n; i++) {
for (let i = 0; i < n; i++) {
win32.extname(i % 3 === 0 ? `${path}${i}` : path);
}
bench.end(n);
Expand Down
2 changes: 1 addition & 1 deletion benchmark/path/format-posix.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function main({ n, props }) {
};

bench.start();
for (var i = 0; i < n; i++) {
for (let i = 0; i < n; i++) {
obj.base = `a${i}${props[2] || ''}`;
obj.name = `a${i}${props[4] || ''}`;
posix.format(obj);
Expand Down
2 changes: 1 addition & 1 deletion benchmark/path/format-win32.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function main({ n, props }) {
};

bench.start();
for (var i = 0; i < n; i++) {
for (let i = 0; i < n; i++) {
obj.base = `a${i}${props[2] || ''}`;
obj.name = `a${i}${props[4] || ''}`;
win32.format(obj);
Expand Down
2 changes: 1 addition & 1 deletion benchmark/path/isAbsolute-posix.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const bench = common.createBenchmark(main, {

function main({ n, path }) {
bench.start();
for (var i = 0; i < n; i++) {
for (let i = 0; i < n; i++) {
posix.isAbsolute(i % 3 === 0 ? `${path}${i}` : path);
}
bench.end(n);
Expand Down
2 changes: 1 addition & 1 deletion benchmark/path/isAbsolute-win32.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const bench = common.createBenchmark(main, {

function main({ n, path }) {
bench.start();
for (var i = 0; i < n; i++) {
for (let i = 0; i < n; i++) {
win32.isAbsolute(i % 3 === 0 ? `${path}${i}` : path);
}
bench.end(n);
Expand Down
2 changes: 1 addition & 1 deletion benchmark/path/join-posix.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function main({ n, paths }) {
const orig = copy[1];

bench.start();
for (var i = 0; i < n; i++) {
for (let i = 0; i < n; i++) {
if (i % 3 === 0) {
copy[1] = `${orig}${i}`;
posix.join(...copy);
Expand Down
2 changes: 1 addition & 1 deletion benchmark/path/join-win32.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function main({ n, paths }) {
const orig = copy[1];

bench.start();
for (var i = 0; i < n; i++) {
for (let i = 0; i < n; i++) {
if (i % 3 === 0) {
copy[1] = `${orig}${i}`;
win32.join(...copy);
Expand Down
2 changes: 1 addition & 1 deletion benchmark/path/makeLong-win32.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const bench = common.createBenchmark(main, {

function main({ n, path }) {
bench.start();
for (var i = 0; i < n; i++) {
for (let i = 0; i < n; i++) {
win32._makeLong(i % 3 === 0 ? `${path}${i}` : path);
}
bench.end(n);
Expand Down
2 changes: 1 addition & 1 deletion benchmark/path/normalize-posix.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const bench = common.createBenchmark(main, {

function main({ n, path }) {
bench.start();
for (var i = 0; i < n; i++) {
for (let i = 0; i < n; i++) {
posix.normalize(i % 3 === 0 ? `${path}${i}` : path);
}
bench.end(n);
Expand Down
2 changes: 1 addition & 1 deletion benchmark/path/normalize-win32.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const bench = common.createBenchmark(main, {

function main({ n, path }) {
bench.start();
for (var i = 0; i < n; i++) {
for (let i = 0; i < n; i++) {
win32.normalize(i % 3 === 0 ? `${path}${i}` : path);
}
bench.end(n);
Expand Down
2 changes: 1 addition & 1 deletion benchmark/path/resolve-posix.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function main({ n, paths }) {
const orig = copy[0];

bench.start();
for (var i = 0; i < n; i++) {
for (let i = 0; i < n; i++) {
if (i % 3 === 0) {
copy[0] = `${orig}${i}`;
posix.resolve(...copy);
Expand Down
2 changes: 1 addition & 1 deletion benchmark/path/resolve-win32.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function main({ n, paths }) {
const orig = copy[0];

bench.start();
for (var i = 0; i < n; i++) {
for (let i = 0; i < n; i++) {
if (i % 3 === 0) {
copy[0] = `${orig}${i}`;
win32.resolve(...copy);
Expand Down
2 changes: 1 addition & 1 deletion benchmark/process/memoryUsage.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const bench = common.createBenchmark(main, {

function main({ n }) {
bench.start();
for (var i = 0; i < n; i++) {
for (let i = 0; i < n; i++) {
process.memoryUsage();
}
bench.end(n);
Expand Down
2 changes: 1 addition & 1 deletion benchmark/process/next-tick-breadth-args.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function main({ n }) {
}

bench.start();
for (var i = 0; i < n; i++) {
for (let i = 0; i < n; i++) {
if (i % 4 === 0)
process.nextTick(cb4, 3.14, 1024, true, false);
else if (i % 3 === 0)
Expand Down
2 changes: 1 addition & 1 deletion benchmark/process/next-tick-breadth.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function main({ n }) {
}

bench.start();
for (var i = 0; i < n; i++) {
for (let i = 0; i < n; i++) {
process.nextTick(cb);
}
}
2 changes: 1 addition & 1 deletion benchmark/process/next-tick-exec-args.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function main({ n }) {
bench.end(n);
}

for (var i = 0; i < n; i++) {
for (let i = 0; i < n; i++) {
if (i % 4 === 0)
process.nextTick(onNextTick, i, true, 10, 'test');
else if (i % 3 === 0)
Expand Down
2 changes: 1 addition & 1 deletion benchmark/process/next-tick-exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function main({ n }) {
bench.end(n);
}

for (var i = 0; i < n; i++) {
for (let i = 0; i < n; i++) {
process.nextTick(onNextTick, i);
}

Expand Down
2 changes: 1 addition & 1 deletion benchmark/process/queue-microtask-breadth.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function main({ n }) {
}

bench.start();
for (var i = 0; i < n; i++) {
for (let i = 0; i < n; i++) {
queueMicrotask(cb);
}
}
2 changes: 1 addition & 1 deletion benchmark/querystring/querystring-stringify.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function main({ type, n }) {
querystring.stringify(inputs[name]);

bench.start();
for (var i = 0; i < n; i += 1)
for (let i = 0; i < n; i += 1)
querystring.stringify(input);
bench.end(n);
}
2 changes: 1 addition & 1 deletion benchmark/querystring/querystring-unescapebuffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const bench = common.createBenchmark(main, {

function main({ input, n }) {
bench.start();
for (var i = 0; i < n; i += 1)
for (let i = 0; i < n; i += 1)
querystring.unescapeBuffer(input);
bench.end(n);
}
2 changes: 1 addition & 1 deletion benchmark/string_decoder/string-decoder-create.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const bench = common.createBenchmark(main, {

function main({ encoding, n }) {
bench.start();
for (var i = 0; i < n; ++i) {
for (let i = 0; i < n; ++i) {
const sd = new StringDecoder(encoding);
!!sd.encoding;
}
Expand Down
8 changes: 4 additions & 4 deletions benchmark/timers/immediate.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function breadth(N) {
if (n === N)
bench.end(N);
}
for (var i = 0; i < N; i++) {
for (let i = 0; i < N; i++) {
setImmediate(cb);
}
}
Expand All @@ -80,7 +80,7 @@ function breadth1(N) {
if (n === N)
bench.end(n);
}
for (var i = 0; i < N; i++) {
for (let i = 0; i < N; i++) {
setImmediate(cb, 1);
}
}
Expand All @@ -95,7 +95,7 @@ function breadth4(N) {
if (n === N)
bench.end(n);
}
for (var i = 0; i < N; i++) {
for (let i = 0; i < N; i++) {
setImmediate(cb, 1, 2, 3, 4);
}
}
Expand All @@ -107,7 +107,7 @@ function clear(N) {
if (a1 === 2)
bench.end(N);
}
for (var i = 0; i < N; i++) {
for (let i = 0; i < N; i++) {
clearImmediate(setImmediate(cb, 1));
}
setImmediate(cb, 2);
Expand Down
2 changes: 1 addition & 1 deletion benchmark/timers/timers-breadth-args.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function main({ n }) {
}

bench.start();
for (var i = 0; i < n; i++) {
for (let i = 0; i < n; i++) {
if (i % 4 === 0)
setTimeout(cb4, 1, 3.14, 1024, true, false);
else if (i % 3 === 0)
Expand Down
2 changes: 1 addition & 1 deletion benchmark/timers/timers-breadth.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function main({ n }) {
if (j === n)
bench.end(n);
}
for (var i = 0; i < n; i++) {
for (let i = 0; i < n; i++) {
setTimeout(cb, 1);
}
}
4 changes: 2 additions & 2 deletions benchmark/timers/timers-cancel-pooled.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ const bench = common.createBenchmark(main, {
function main({ n }) {

var timer = setTimeout(() => {}, 1);
for (var i = 0; i < n; i++) {
for (let i = 0; i < n; i++) {
setTimeout(cb, 1);
}
var next = timer._idlePrev;
clearTimeout(timer);

bench.start();

for (var j = 0; j < n; j++) {
for (let j = 0; j < n; j++) {
timer = next;
next = timer._idlePrev;
clearTimeout(timer);
Expand Down
2 changes: 1 addition & 1 deletion benchmark/timers/timers-cancel-unpooled.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const bench = common.createBenchmark(main, {
function main({ n, direction }) {

const timersList = [];
for (var i = 0; i < n; i++) {
for (let i = 0; i < n; i++) {
timersList.push(setTimeout(cb, i + 1));
}

Expand Down
2 changes: 1 addition & 1 deletion benchmark/timers/timers-insert-pooled.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function main({ n }) {

bench.start();

for (var i = 0; i < n; i++) {
for (let i = 0; i < n; i++) {
setTimeout(() => {}, 1);
}

Expand Down
2 changes: 1 addition & 1 deletion benchmark/timers/timers-insert-unpooled.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function main({ direction, n }) {
}
bench.end(n);

for (var j = 0; j < n; j++) {
for (let j = 0; j < n; j++) {
clearTimeout(timersList[j]);
}
}
Expand Down
2 changes: 1 addition & 1 deletion benchmark/timers/timers-timeout-nexttick.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function main({ n }) {
bench.end(n);
}

for (var i = 0; i < n; i++) {
for (let i = 0; i < n; i++) {
setTimeout(i % 2 ? cb : cb2, 1);
}

Expand Down
2 changes: 1 addition & 1 deletion benchmark/timers/timers-timeout-pooled.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function main({ n }) {
bench.end(n);
}

for (var i = 0; i < n; i++) {
for (let i = 0; i < n; i++) {
setTimeout(i % 2 ? cb : cb2, 1);
}

Expand Down
Loading

0 comments on commit d0ed431

Please sign in to comment.