Skip to content

Commit 4ee5665

Browse files
dnluptargos
authored andcommitted
benchmark: use let instead of var in dgram
PR-URL: #31175 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com>
1 parent 18cd002 commit 4ee5665

5 files changed

Lines changed: 17 additions & 18 deletions

File tree

‎benchmark/dgram/array-vs-concat.js‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ const bench = common.createBenchmark(main, {
1818

1919
functionmain({ dur, len, num, type, chunks }){
2020
constchunk=[];
21-
for(vari=0;i<chunks;i++){
21+
for(leti=0;i<chunks;i++){
2222
chunk.push(Buffer.allocUnsafe(Math.round(len/chunks)));
2323
}
2424

2525
// Server
26-
varsent=0;
26+
letsent=0;
2727
constsocket=dgram.createSocket('udp4');
2828
constonsend=type==='concat' ? onsendConcat : onsendMulti;
2929

@@ -32,7 +32,7 @@ function main({ dur, len, num, type, chunks }) {
3232
// The setImmediate() is necessary to have event loop progress on OSes
3333
// that only perform synchronous I/O on nonblocking UDP sockets.
3434
setImmediate(()=>{
35-
for(vari=0;i<num;i++){
35+
for(leti=0;i<num;i++){
3636
socket.send(Buffer.concat(chunk),PORT,'127.0.0.1',onsend);
3737
}
3838
});
@@ -44,7 +44,7 @@ function main({ dur, len, num, type, chunks }) {
4444
// The setImmediate() is necessary to have event loop progress on OSes
4545
// that only perform synchronous I/O on nonblocking UDP sockets.
4646
setImmediate(()=>{
47-
for(vari=0;i<num;i++){
47+
for(leti=0;i<num;i++){
4848
socket.send(chunk,PORT,'127.0.0.1',onsend);
4949
}
5050
});

‎benchmark/dgram/bind-params.js‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,18 @@ const noop = () => {};
1515
functionmain({ n, port, address }){
1616
port=port==='true' ? 0 : undefined;
1717
address=address==='true' ? '0.0.0.0' : undefined;
18-
vari;
1918

2019
if(port!==undefined&&address!==undefined){
2120
bench.start();
22-
for(i=0;i<n;i++){
21+
for(leti=0;i<n;i++){
2322
dgram.createSocket('udp4').bind(port,address)
2423
.on('error',noop)
2524
.unref();
2625
}
2726
bench.end(n);
2827
}elseif(port!==undefined){
2928
bench.start();
30-
for(i=0;i<n;i++){
29+
for(leti=0;i<n;i++){
3130
dgram.createSocket('udp4')
3231
.bind(port)
3332
.on('error',noop)
@@ -36,7 +35,7 @@ function main({ n, port, address }) {
3635
bench.end(n);
3736
}elseif(port===undefined&&address===undefined){
3837
bench.start();
39-
for(i=0;i<n;i++){
38+
for(leti=0;i<n;i++){
4039
dgram.createSocket('udp4')
4140
.bind()
4241
.on('error',noop)

‎benchmark/dgram/multi-buffer.js‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,19 @@ const bench = common.createBenchmark(main, {
1818

1919
functionmain({ dur, len, num, type, chunks }){
2020
constchunk=[];
21-
for(vari=0;i<chunks;i++){
21+
for(leti=0;i<chunks;i++){
2222
chunk.push(Buffer.allocUnsafe(Math.round(len/chunks)));
2323
}
24-
varsent=0;
25-
varreceived=0;
24+
letsent=0;
25+
letreceived=0;
2626
constsocket=dgram.createSocket('udp4');
2727

2828
functiononsend(){
2929
if(sent++%num===0){
3030
// The setImmediate() is necessary to have event loop progress on OSes
3131
// that only perform synchronous I/O on nonblocking UDP sockets.
3232
setImmediate(()=>{
33-
for(vari=0;i<num;i++){
33+
for(leti=0;i<num;i++){
3434
socket.send(chunk,PORT,'127.0.0.1',onsend);
3535
}
3636
});

‎benchmark/dgram/offset-length.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@ const bench = common.createBenchmark(main, {
1717

1818
functionmain({ dur, len, num, type }){
1919
constchunk=Buffer.allocUnsafe(len);
20-
varsent=0;
21-
varreceived=0;
20+
letsent=0;
21+
letreceived=0;
2222
constsocket=dgram.createSocket('udp4');
2323

2424
functiononsend(){
2525
if(sent++%num===0){
2626
// The setImmediate() is necessary to have event loop progress on OSes
2727
// that only perform synchronous I/O on nonblocking UDP sockets.
2828
setImmediate(()=>{
29-
for(vari=0;i<num;i++){
29+
for(leti=0;i<num;i++){
3030
socket.send(chunk,0,chunk.length,PORT,'127.0.0.1',onsend);
3131
}
3232
});

‎benchmark/dgram/single-buffer.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@ const bench = common.createBenchmark(main, {
1717

1818
functionmain({ dur, len, num, type }){
1919
constchunk=Buffer.allocUnsafe(len);
20-
varsent=0;
21-
varreceived=0;
20+
letsent=0;
21+
letreceived=0;
2222
constsocket=dgram.createSocket('udp4');
2323

2424
functiononsend(){
2525
if(sent++%num===0){
2626
// The setImmediate() is necessary to have event loop progress on OSes
2727
// that only perform synchronous I/O on nonblocking UDP sockets.
2828
setImmediate(()=>{
29-
for(vari=0;i<num;i++){
29+
for(leti=0;i<num;i++){
3030
socket.send(chunk,PORT,'127.0.0.1',onsend);
3131
}
3232
});

0 commit comments

Comments
 (0)