Skip to content

Commit 2de085f

Browse files
dnlupcodebytere
authored andcommitted
benchmark: use let instead of var
Use `let` in module, napi, net, os, path, process, querystring, streams and string_decoder. PR-URL: #31592 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent e37f510 commit 2de085f

30 files changed

+75
-80
lines changed

benchmark/module/module-loader-deep.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,13 @@ function main({ ext, cache, files }) {
3737
}
3838

3939
function measureDir(cache, files) {
40-
var i;
4140
if (cache) {
42-
for (i = 0; i <= files; i++) {
41+
for (let i = 0; i <= files; i++) {
4342
require(`${benchmarkDirectory}/${i}`);
4443
}
4544
}
4645
bench.start();
47-
for (i = 0; i <= files; i++) {
46+
for (let i = 0; i <= files; i++) {
4847
require(`${benchmarkDirectory}/${i}`);
4948
}
5049
bench.end(files);

benchmark/module/module-loader.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,14 @@ function main({ n, name, cache, files, dir }) {
4242
}
4343

4444
function measureDir(n, cache, files, name) {
45-
var i;
4645
if (cache) {
47-
for (i = 0; i <= files; i++) {
46+
for (let i = 0; i <= files; i++) {
4847
require(`${benchmarkDirectory}${i}${name}`);
4948
}
5049
}
5150
bench.start();
52-
for (i = 0; i <= files; i++) {
53-
for (var j = 0; j < n; j++)
51+
for (let i = 0; i <= files; i++) {
52+
for (let j = 0; j < n; j++)
5453
require(`${benchmarkDirectory}${i}${name}`);
5554
// Pretend mixed input (otherwise the results are less representative due to
5655
// highly specialized code).

benchmark/napi/function_args/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ function main({ n, engine, type }) {
8989
const args = generateArgs(type);
9090

9191
bench.start();
92-
for (var i = 0; i < n; i++) {
92+
for (let i = 0; i < n; i++) {
9393
fn.apply(null, args);
9494
}
9595
bench.end(n);

benchmark/napi/function_call/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ try {
2929
}
3030
const napi = napi_binding.hello;
3131

32-
var c = 0;
32+
let c = 0;
3333
function js() {
3434
return c++;
3535
}
@@ -44,7 +44,7 @@ const bench = common.createBenchmark(main, {
4444
function main({ n, type }) {
4545
const fn = type === 'cxx' ? cxx : type === 'napi' ? napi : js;
4646
bench.start();
47-
for (var i = 0; i < n; i++) {
47+
for (let i = 0; i < n; i++) {
4848
fn();
4949
}
5050
bench.end(n);

benchmark/net/net-c2s-cork.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ const bench = common.createBenchmark(main, {
1111
dur: [5],
1212
});
1313

14-
var chunk;
15-
var encoding;
14+
let chunk;
15+
let encoding;
1616

1717
function main({ dur, len, type }) {
1818
switch (type) {

benchmark/net/net-c2s.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ const bench = common.createBenchmark(main, {
1111
dur: [5],
1212
});
1313

14-
var chunk;
15-
var encoding;
14+
let chunk;
15+
let encoding;
1616

1717
function main({ dur, len, type }) {
1818
switch (type) {

benchmark/net/net-pipe.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ const bench = common.createBenchmark(main, {
1111
dur: [5],
1212
});
1313

14-
var chunk;
15-
var encoding;
14+
let chunk;
15+
let encoding;
1616

1717
function main({ dur, len, type }) {
1818
switch (type) {

benchmark/net/net-s2c.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ const bench = common.createBenchmark(main, {
1212
dur: [5]
1313
});
1414

15-
var chunk;
16-
var encoding;
17-
var recvbuf;
18-
var received = 0;
15+
let chunk;
16+
let encoding;
17+
let recvbuf;
18+
let received = 0;
1919

2020
function main({ dur, sendchunklen, type, recvbuflen, recvbufgenfn }) {
2121
if (isFinite(recvbuflen) && recvbuflen > 0)
@@ -38,8 +38,8 @@ function main({ dur, sendchunklen, type, recvbuflen, recvbufgenfn }) {
3838
}
3939

4040
const reader = new Reader();
41-
var writer;
42-
var socketOpts;
41+
let writer;
42+
let socketOpts;
4343
if (recvbuf === undefined) {
4444
writer = new Writer();
4545
socketOpts = { port: PORT };

benchmark/net/net-wrap-js-stream-passthrough.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ const bench = common.createBenchmark(main, {
1212
flags: ['--expose-internals']
1313
});
1414

15-
var chunk;
16-
var encoding;
15+
let chunk;
16+
let encoding;
1717

1818
function main({ dur, len, type }) {
1919
// Can only require internals inside main().

benchmark/net/tcp-raw-c2s.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function main({ dur, len, type }) {
2424
const PORT = common.PORT;
2525

2626
const serverHandle = new TCP(TCPConstants.SERVER);
27-
var err = serverHandle.bind('127.0.0.1', PORT);
27+
let err = serverHandle.bind('127.0.0.1', PORT);
2828
if (err)
2929
fail(err, 'bind');
3030

@@ -38,7 +38,7 @@ function main({ dur, len, type }) {
3838

3939
// The meat of the benchmark is right here:
4040
bench.start();
41-
var bytes = 0;
41+
let bytes = 0;
4242

4343
setTimeout(() => {
4444
// report in Gb/sec
@@ -67,7 +67,7 @@ function main({ dur, len, type }) {
6767
}
6868

6969
function client(type, len) {
70-
var chunk;
70+
let chunk;
7171
switch (type) {
7272
case 'buf':
7373
chunk = Buffer.alloc(len, 'x');
@@ -102,7 +102,7 @@ function main({ dur, len, type }) {
102102
function write() {
103103
const writeReq = new WriteWrap();
104104
writeReq.oncomplete = afterWrite;
105-
var err;
105+
let err;
106106
switch (type) {
107107
case 'buf':
108108
err = clientHandle.writeBuffer(writeReq, chunk);

0 commit comments

Comments
 (0)