benchmark: swap var for let in benchmarks

In benchmark directory this changes for loops
using var to let when it applies for consistency

PR-URL: https://github.com/nodejs/node/pull/28958
Reviewed-By: Anna Henningsen <anna@addaleax.net>
This commit is contained in:
Alex Ramirez authored and Anna Henningsen committed 2020-02-13 21:38:00 +01:00
1 parent 9e805b1fbf
commit d0ed431041
47 files changed
+51 -51

No files matched your search

+1 -1
View File
@@ -19,7 +19,7 @@ function main({ ext, cache, files }) {
`${benchmarkDirectory}/a.js`, `${benchmarkDirectory}/a.js`,
'module.exports = {};' 'module.exports = {};'
); );
for (var i = 0; i <= files; i++) { for (let i = 0; i <= files; i++) {
fs.mkdirSync(`${benchmarkDirectory}/${i}`); fs.mkdirSync(`${benchmarkDirectory}/${i}`);
fs.writeFileSync( fs.writeFileSync(
`${benchmarkDirectory}/${i}/package.json`, `${benchmarkDirectory}/${i}/package.json`,
+1 -1
View File
@@ -21,7 +21,7 @@ const bench = common.createBenchmark(main, {
function main({ n, name, cache, files, dir }) { function main({ n, name, cache, files, dir }) {
tmpdir.refresh(); tmpdir.refresh();
fs.mkdirSync(benchmarkDirectory); fs.mkdirSync(benchmarkDirectory);
for (var i = 0; i <= files; i++) { for (let i = 0; i <= files; i++) {
fs.mkdirSync(`${benchmarkDirectory}${i}`); fs.mkdirSync(`${benchmarkDirectory}${i}`);
fs.writeFileSync( fs.writeFileSync(
`${benchmarkDirectory}${i}/package.json`, `${benchmarkDirectory}${i}/package.json`,
+1 -1
View File
@@ -9,7 +9,7 @@ const bench = common.createBenchmark(main, {
function main({ n }) { function main({ n }) {
bench.start(); bench.start();
for (var i = 0; i < n; ++i) for (let i = 0; i < n; ++i)
cpus(); cpus();
bench.end(n); bench.end(n);
} }
+1 -1
View File
@@ -9,7 +9,7 @@ const bench = common.createBenchmark(main, {
function main({ n }) { function main({ n }) {
bench.start(); bench.start();
for (var i = 0; i < n; ++i) for (let i = 0; i < n; ++i)
loadavg(); loadavg();
bench.end(n); bench.end(n);
} }
+1 -1
View File
@@ -9,7 +9,7 @@ const bench = common.createBenchmark(main, {
function main({ n }) { function main({ n }) {
bench.start(); bench.start();
for (var i = 0; i < n; ++i) for (let i = 0; i < n; ++i)
networkInterfaces(); networkInterfaces();
bench.end(n); bench.end(n);
} }
+1 -1
View File
@@ -27,7 +27,7 @@ function main({ n, pathext }) {
} }
bench.start(); 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); posix.basename(i % 3 === 0 ? `${pathext}${i}` : pathext, ext);
} }
bench.end(n); bench.end(n);
+1 -1
View File
@@ -27,7 +27,7 @@ function main({ n, pathext }) {
} }
bench.start(); 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); win32.basename(i % 3 === 0 ? `${pathext}${i}` : pathext, ext);
} }
bench.end(n); bench.end(n);
+1 -1
View File
@@ -17,7 +17,7 @@ const bench = common.createBenchmark(main, {
function main({ n, path }) { function main({ n, path }) {
bench.start(); bench.start();
for (var i = 0; i < n; i++) { for (let i = 0; i < n; i++) {
posix.dirname(i % 3 === 0 ? `${path}${i}` : path); posix.dirname(i % 3 === 0 ? `${path}${i}` : path);
} }
bench.end(n); bench.end(n);
+1 -1
View File
@@ -17,7 +17,7 @@ const bench = common.createBenchmark(main, {
function main({ n, path }) { function main({ n, path }) {
bench.start(); bench.start();
for (var i = 0; i < n; i++) { for (let i = 0; i < n; i++) {
win32.dirname(i % 3 === 0 ? `${path}${i}` : path); win32.dirname(i % 3 === 0 ? `${path}${i}` : path);
} }
bench.end(n); bench.end(n);
+1 -1
View File
@@ -20,7 +20,7 @@ const bench = common.createBenchmark(main, {
function main({ n, path }) { function main({ n, path }) {
bench.start(); bench.start();
for (var i = 0; i < n; i++) { for (let i = 0; i < n; i++) {
posix.extname(i % 3 === 0 ? `${path}${i}` : path); posix.extname(i % 3 === 0 ? `${path}${i}` : path);
} }
bench.end(n); bench.end(n);
+1 -1
View File
@@ -20,7 +20,7 @@ const bench = common.createBenchmark(main, {
function main({ n, path }) { function main({ n, path }) {
bench.start(); bench.start();
for (var i = 0; i < n; i++) { for (let i = 0; i < n; i++) {
win32.extname(i % 3 === 0 ? `${path}${i}` : path); win32.extname(i % 3 === 0 ? `${path}${i}` : path);
} }
bench.end(n); bench.end(n);
+1 -1
View File
@@ -20,7 +20,7 @@ function main({ n, props }) {
}; };
bench.start(); bench.start();
for (var i = 0; i < n; i++) { for (let i = 0; i < n; i++) {
obj.base = `a${i}${props[2] || ''}`; obj.base = `a${i}${props[2] || ''}`;
obj.name = `a${i}${props[4] || ''}`; obj.name = `a${i}${props[4] || ''}`;
posix.format(obj); posix.format(obj);
+1 -1
View File
@@ -20,7 +20,7 @@ function main({ n, props }) {
}; };
bench.start(); bench.start();
for (var i = 0; i < n; i++) { for (let i = 0; i < n; i++) {
obj.base = `a${i}${props[2] || ''}`; obj.base = `a${i}${props[2] || ''}`;
obj.name = `a${i}${props[4] || ''}`; obj.name = `a${i}${props[4] || ''}`;
win32.format(obj); win32.format(obj);
+1 -1
View File
@@ -15,7 +15,7 @@ const bench = common.createBenchmark(main, {
function main({ n, path }) { function main({ n, path }) {
bench.start(); bench.start();
for (var i = 0; i < n; i++) { for (let i = 0; i < n; i++) {
posix.isAbsolute(i % 3 === 0 ? `${path}${i}` : path); posix.isAbsolute(i % 3 === 0 ? `${path}${i}` : path);
} }
bench.end(n); bench.end(n);
+1 -1
View File
@@ -16,7 +16,7 @@ const bench = common.createBenchmark(main, {
function main({ n, path }) { function main({ n, path }) {
bench.start(); bench.start();
for (var i = 0; i < n; i++) { for (let i = 0; i < n; i++) {
win32.isAbsolute(i % 3 === 0 ? `${path}${i}` : path); win32.isAbsolute(i % 3 === 0 ? `${path}${i}` : path);
} }
bench.end(n); bench.end(n);
+1 -1
View File
@@ -15,7 +15,7 @@ function main({ n, paths }) {
const orig = copy[1]; const orig = copy[1];
bench.start(); bench.start();
for (var i = 0; i < n; i++) { for (let i = 0; i < n; i++) {
if (i % 3 === 0) { if (i % 3 === 0) {
copy[1] = `${orig}${i}`; copy[1] = `${orig}${i}`;
posix.join(...copy); posix.join(...copy);
+1 -1
View File
@@ -15,7 +15,7 @@ function main({ n, paths }) {
const orig = copy[1]; const orig = copy[1];
bench.start(); bench.start();
for (var i = 0; i < n; i++) { for (let i = 0; i < n; i++) {
if (i % 3 === 0) { if (i % 3 === 0) {
copy[1] = `${orig}${i}`; copy[1] = `${orig}${i}`;
win32.join(...copy); win32.join(...copy);
+1 -1
View File
@@ -14,7 +14,7 @@ const bench = common.createBenchmark(main, {
function main({ n, path }) { function main({ n, path }) {
bench.start(); bench.start();
for (var i = 0; i < n; i++) { for (let i = 0; i < n; i++) {
win32._makeLong(i % 3 === 0 ? `${path}${i}` : path); win32._makeLong(i % 3 === 0 ? `${path}${i}` : path);
} }
bench.end(n); bench.end(n);
+1 -1
View File
@@ -16,7 +16,7 @@ const bench = common.createBenchmark(main, {
function main({ n, path }) { function main({ n, path }) {
bench.start(); bench.start();
for (var i = 0; i < n; i++) { for (let i = 0; i < n; i++) {
posix.normalize(i % 3 === 0 ? `${path}${i}` : path); posix.normalize(i % 3 === 0 ? `${path}${i}` : path);
} }
bench.end(n); bench.end(n);
+1 -1
View File
@@ -16,7 +16,7 @@ const bench = common.createBenchmark(main, {
function main({ n, path }) { function main({ n, path }) {
bench.start(); bench.start();
for (var i = 0; i < n; i++) { for (let i = 0; i < n; i++) {
win32.normalize(i % 3 === 0 ? `${path}${i}` : path); win32.normalize(i % 3 === 0 ? `${path}${i}` : path);
} }
bench.end(n); bench.end(n);
+1 -1
View File
@@ -18,7 +18,7 @@ function main({ n, paths }) {
const orig = copy[0]; const orig = copy[0];
bench.start(); bench.start();
for (var i = 0; i < n; i++) { for (let i = 0; i < n; i++) {
if (i % 3 === 0) { if (i % 3 === 0) {
copy[0] = `${orig}${i}`; copy[0] = `${orig}${i}`;
posix.resolve(...copy); posix.resolve(...copy);
+1 -1
View File
@@ -18,7 +18,7 @@ function main({ n, paths }) {
const orig = copy[0]; const orig = copy[0];
bench.start(); bench.start();
for (var i = 0; i < n; i++) { for (let i = 0; i < n; i++) {
if (i % 3 === 0) { if (i % 3 === 0) {
copy[0] = `${orig}${i}`; copy[0] = `${orig}${i}`;
win32.resolve(...copy); win32.resolve(...copy);
+1 -1
View File
@@ -7,7 +7,7 @@ const bench = common.createBenchmark(main, {
function main({ n }) { function main({ n }) {
bench.start(); bench.start();
for (var i = 0; i < n; i++) { for (let i = 0; i < n; i++) {
process.memoryUsage(); process.memoryUsage();
} }
bench.end(n); bench.end(n);
+1 -1
View File
@@ -33,7 +33,7 @@ function main({ n }) {
} }
bench.start(); bench.start();
for (var i = 0; i < n; i++) { for (let i = 0; i < n; i++) {
if (i % 4 === 0) if (i % 4 === 0)
process.nextTick(cb4, 3.14, 1024, true, false); process.nextTick(cb4, 3.14, 1024, true, false);
else if (i % 3 === 0) else if (i % 3 === 0)
+1 -1
View File
@@ -15,7 +15,7 @@ function main({ n }) {
} }
bench.start(); bench.start();
for (var i = 0; i < n; i++) { for (let i = 0; i < n; i++) {
process.nextTick(cb); process.nextTick(cb);
} }
} }
+1 -1
View File
@@ -10,7 +10,7 @@ function main({ n }) {
bench.end(n); bench.end(n);
} }
for (var i = 0; i < n; i++) { for (let i = 0; i < n; i++) {
if (i % 4 === 0) if (i % 4 === 0)
process.nextTick(onNextTick, i, true, 10, 'test'); process.nextTick(onNextTick, i, true, 10, 'test');
else if (i % 3 === 0) else if (i % 3 === 0)
+1 -1
View File
@@ -10,7 +10,7 @@ function main({ n }) {
bench.end(n); bench.end(n);
} }
for (var i = 0; i < n; i++) { for (let i = 0; i < n; i++) {
process.nextTick(onNextTick, i); process.nextTick(onNextTick, i);
} }
+1 -1
View File
@@ -15,7 +15,7 @@ function main({ n }) {
} }
bench.start(); bench.start();
for (var i = 0; i < n; i++) { for (let i = 0; i < n; i++) {
queueMicrotask(cb); queueMicrotask(cb);
} }
} }
@@ -38,7 +38,7 @@ function main({ type, n }) {
querystring.stringify(inputs[name]); querystring.stringify(inputs[name]);
bench.start(); bench.start();
for (var i = 0; i < n; i += 1) for (let i = 0; i < n; i += 1)
querystring.stringify(input); querystring.stringify(input);
bench.end(n); bench.end(n);
} }
@@ -14,7 +14,7 @@ const bench = common.createBenchmark(main, {
function main({ input, n }) { function main({ input, n }) {
bench.start(); bench.start();
for (var i = 0; i < n; i += 1) for (let i = 0; i < n; i += 1)
querystring.unescapeBuffer(input); querystring.unescapeBuffer(input);
bench.end(n); bench.end(n);
} }
@@ -11,7 +11,7 @@ const bench = common.createBenchmark(main, {
function main({ encoding, n }) { function main({ encoding, n }) {
bench.start(); bench.start();
for (var i = 0; i < n; ++i) { for (let i = 0; i < n; ++i) {
const sd = new StringDecoder(encoding); const sd = new StringDecoder(encoding);
!!sd.encoding; !!sd.encoding;
} }
+4 -4
View File
@@ -66,7 +66,7 @@ function breadth(N) {
if (n === N) if (n === N)
bench.end(N); bench.end(N);
} }
for (var i = 0; i < N; i++) { for (let i = 0; i < N; i++) {
setImmediate(cb); setImmediate(cb);
} }
} }
@@ -80,7 +80,7 @@ function breadth1(N) {
if (n === N) if (n === N)
bench.end(n); bench.end(n);
} }
for (var i = 0; i < N; i++) { for (let i = 0; i < N; i++) {
setImmediate(cb, 1); setImmediate(cb, 1);
} }
} }
@@ -95,7 +95,7 @@ function breadth4(N) {
if (n === N) if (n === N)
bench.end(n); bench.end(n);
} }
for (var i = 0; i < N; i++) { for (let i = 0; i < N; i++) {
setImmediate(cb, 1, 2, 3, 4); setImmediate(cb, 1, 2, 3, 4);
} }
} }
@@ -107,7 +107,7 @@ function clear(N) {
if (a1 === 2) if (a1 === 2)
bench.end(N); bench.end(N);
} }
for (var i = 0; i < N; i++) { for (let i = 0; i < N; i++) {
clearImmediate(setImmediate(cb, 1)); clearImmediate(setImmediate(cb, 1));
} }
setImmediate(cb, 2); setImmediate(cb, 2);
+1 -1
View File
@@ -32,7 +32,7 @@ function main({ n }) {
} }
bench.start(); bench.start();
for (var i = 0; i < n; i++) { for (let i = 0; i < n; i++) {
if (i % 4 === 0) if (i % 4 === 0)
setTimeout(cb4, 1, 3.14, 1024, true, false); setTimeout(cb4, 1, 3.14, 1024, true, false);
else if (i % 3 === 0) else if (i % 3 === 0)
+1 -1
View File
@@ -13,7 +13,7 @@ function main({ n }) {
if (j === n) if (j === n)
bench.end(n); bench.end(n);
} }
for (var i = 0; i < n; i++) { for (let i = 0; i < n; i++) {
setTimeout(cb, 1); setTimeout(cb, 1);
} }
} }
+2 -2
View File
@@ -9,7 +9,7 @@ const bench = common.createBenchmark(main, {
function main({ n }) { function main({ n }) {
var timer = setTimeout(() => {}, 1); var timer = setTimeout(() => {}, 1);
for (var i = 0; i < n; i++) { for (let i = 0; i < n; i++) {
setTimeout(cb, 1); setTimeout(cb, 1);
} }
var next = timer._idlePrev; var next = timer._idlePrev;
@@ -17,7 +17,7 @@ function main({ n }) {
bench.start(); bench.start();
for (var j = 0; j < n; j++) { for (let j = 0; j < n; j++) {
timer = next; timer = next;
next = timer._idlePrev; next = timer._idlePrev;
clearTimeout(timer); clearTimeout(timer);
+1 -1
View File
@@ -10,7 +10,7 @@ const bench = common.createBenchmark(main, {
function main({ n, direction }) { function main({ n, direction }) {
const timersList = []; const timersList = [];
for (var i = 0; i < n; i++) { for (let i = 0; i < n; i++) {
timersList.push(setTimeout(cb, i + 1)); timersList.push(setTimeout(cb, i + 1));
} }
+1 -1
View File
@@ -9,7 +9,7 @@ function main({ n }) {
bench.start(); bench.start();
for (var i = 0; i < n; i++) { for (let i = 0; i < n; i++) {
setTimeout(() => {}, 1); setTimeout(() => {}, 1);
} }
+1 -1
View File
@@ -23,7 +23,7 @@ function main({ direction, n }) {
} }
bench.end(n); bench.end(n);
for (var j = 0; j < n; j++) { for (let j = 0; j < n; j++) {
clearTimeout(timersList[j]); clearTimeout(timersList[j]);
} }
} }
+1 -1
View File
@@ -30,7 +30,7 @@ function main({ n }) {
bench.end(n); bench.end(n);
} }
for (var i = 0; i < n; i++) { for (let i = 0; i < n; i++) {
setTimeout(i % 2 ? cb : cb2, 1); setTimeout(i % 2 ? cb : cb2, 1);
} }
+1 -1
View File
@@ -27,7 +27,7 @@ function main({ n }) {
bench.end(n); bench.end(n);
} }
for (var i = 0; i < n; i++) { for (let i = 0; i < n; i++) {
setTimeout(i % 2 ? cb : cb2, 1); setTimeout(i % 2 ? cb : cb2, 1);
} }
+1 -1
View File
@@ -27,7 +27,7 @@ function main({ n }) {
bench.end(n); bench.end(n);
} }
for (var i = 0; i < n; i++) { for (let i = 0; i < n; i++) {
// unref().ref() will cause each of these timers to // unref().ref() will cause each of these timers to
// allocate their own handle // allocate their own handle
setTimeout(i % 2 ? cb : cb2, 1).unref().ref(); setTimeout(i % 2 ? cb : cb2, 1).unref().ref();
+1 -1
View File
@@ -16,7 +16,7 @@ function main({ n }) {
m = {}; m = {};
} }
bench.start(); bench.start();
for (var i = 0; i < n; i++) for (let i = 0; i < n; i++)
tls.convertALPNProtocols(input, m); tls.convertALPNProtocols(input, m);
bench.end(n); bench.end(n);
} }
+1 -1
View File
@@ -31,7 +31,7 @@ function main(conf) {
function onListening() { function onListening() {
setTimeout(done, dur * 1000); setTimeout(done, dur * 1000);
bench.start(); bench.start();
for (var i = 0; i < concurrency; i++) for (let i = 0; i < concurrency; i++)
makeConnection(); makeConnection();
} }
+1 -1
View File
@@ -13,7 +13,7 @@ const bench = common.createBenchmark(main, {
function main({ method, n }) { function main({ method, n }) {
bench.start(); bench.start();
for (var i = 0; i < n; i++) for (let i = 0; i < n; i++)
v8[method](); v8[method]();
bench.end(n); bench.end(n);
} }
+1 -1
View File
@@ -20,7 +20,7 @@ function main({ n, breakOnSigint, withSigintListener }) {
const contextifiedSandbox = vm.createContext(); const contextifiedSandbox = vm.createContext();
bench.start(); bench.start();
for (var i = 0; i < n; i++) for (let i = 0; i < n; i++)
vm.runInContext('0', contextifiedSandbox, options); vm.runInContext('0', contextifiedSandbox, options);
bench.end(n); bench.end(n);
} }
+1 -1
View File
@@ -18,7 +18,7 @@ function main({ n, breakOnSigint, withSigintListener }) {
process.on('SIGINT', () => {}); process.on('SIGINT', () => {});
bench.start(); bench.start();
for (var i = 0; i < n; i++) for (let i = 0; i < n; i++)
vm.runInThisContext('0', options); vm.runInThisContext('0', options);
bench.end(n); bench.end(n);
} }
+1 -1
View File
@@ -32,7 +32,7 @@ function main({ n, workers, sendsPerBroadcast: sends, payload: payloadType }) {
const workerObjs = []; const workerObjs = [];
for (var i = 0; i < workers; ++i) { for (let i = 0; i < workers; ++i) {
const worker = new Worker(workerPath); const worker = new Worker(workerPath);
workerObjs.push(worker); workerObjs.push(worker);
worker.on('online', onOnline); worker.on('online', onOnline);