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

Lines changed: 75 additions & 80 deletions

‎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
functionmeasureDir(cache,files){
40-
vari;
4140
if(cache){
42-
for(i=0;i<=files;i++){
41+
for(leti=0;i<=files;i++){
4342
require(`${benchmarkDirectory}/${i}`);
4443
}
4544
}
4645
bench.start();
47-
for(i=0;i<=files;i++){
46+
for(leti=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
functionmeasureDir(n,cache,files,name){
45-
vari;
4645
if(cache){
47-
for(i=0;i<=files;i++){
46+
for(leti=0;i<=files;i++){
4847
require(`${benchmarkDirectory}${i}${name}`);
4948
}
5049
}
5150
bench.start();
52-
for(i=0;i<=files;i++){
53-
for(varj=0;j<n;j++)
51+
for(leti=0;i<=files;i++){
52+
for(letj=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
constargs=generateArgs(type);
9090

9191
bench.start();
92-
for(vari=0;i<n;i++){
92+
for(leti=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
constnapi=napi_binding.hello;
3131

32-
varc=0;
32+
letc=0;
3333
functionjs(){
3434
returnc++;
3535
}
@@ -44,7 +44,7 @@ const bench = common.createBenchmark(main, {
4444
functionmain({ n, type }){
4545
constfn=type==='cxx' ? cxx : type==='napi' ? napi : js;
4646
bench.start();
47-
for(vari=0;i<n;i++){
47+
for(leti=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-
varchunk;
15-
varencoding;
14+
letchunk;
15+
letencoding;
1616

1717
functionmain({ 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-
varchunk;
15-
varencoding;
14+
letchunk;
15+
letencoding;
1616

1717
functionmain({ 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-
varchunk;
15-
varencoding;
14+
letchunk;
15+
letencoding;
1616

1717
functionmain({ 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-
varchunk;
16-
varencoding;
17-
varrecvbuf;
18-
varreceived=0;
15+
letchunk;
16+
letencoding;
17+
letrecvbuf;
18+
letreceived=0;
1919

2020
functionmain({ 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
constreader=newReader();
41-
varwriter;
42-
varsocketOpts;
41+
letwriter;
42+
letsocketOpts;
4343
if(recvbuf===undefined){
4444
writer=newWriter();
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-
varchunk;
16-
varencoding;
15+
letchunk;
16+
letencoding;
1717

1818
functionmain({ 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
constPORT=common.PORT;
2525

2626
constserverHandle=newTCP(TCPConstants.SERVER);
27-
varerr=serverHandle.bind('127.0.0.1',PORT);
27+
leterr=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-
varbytes=0;
41+
letbytes=0;
4242

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

6969
functionclient(type,len){
70-
varchunk;
70+
letchunk;
7171
switch(type){
7272
case'buf':
7373
chunk=Buffer.alloc(len,'x');
@@ -102,7 +102,7 @@ function main({ dur, len, type }) {
102102
functionwrite(){
103103
constwriteReq=newWriteWrap();
104104
writeReq.oncomplete=afterWrite;
105-
varerr;
105+
leterr;
106106
switch(type){
107107
case'buf':
108108
err=clientHandle.writeBuffer(writeReq,chunk);

0 commit comments

Comments
 (0)