Skip to content

Commit d30911e

Browse files
dnluptargos
authored andcommitted
benchmark: use let instead of var in crypto
PR-URL: #31135 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent 25fb34c commit d30911e

6 files changed

Lines changed: 14 additions & 14 deletions

File tree

‎benchmark/crypto/aes-gcm-throughput.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function AEAD_Bench(cipher, message, associate_data, key, iv, n, len) {
2525
constbits=written*8;
2626
constmbits=bits/(1024*1024);
2727

28-
for(vari=0;i<n;i++){
28+
for(leti=0;i<n;i++){
2929
constalice=crypto.createCipheriv(cipher,key,iv);
3030
alice.setAAD(associate_data);
3131
constenc=alice.update(message);

‎benchmark/crypto/cipher-stream.js‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ function main({ api, cipher, type, len, writes }) {
3838
constalice_cipher=crypto.createCipher(cipher,alice_secret);
3939
constbob_cipher=crypto.createDecipher(cipher,bob_secret);
4040

41-
varmessage;
42-
varencoding;
41+
letmessage;
42+
letencoding;
4343
switch(type){
4444
case'asc':
4545
message='a'.repeat(len);
@@ -65,7 +65,7 @@ function main({ api, cipher, type, len, writes }) {
6565
}
6666

6767
functionstreamWrite(alice,bob,message,encoding,writes){
68-
varwritten=0;
68+
letwritten=0;
6969
bob.on('data',(c)=>{
7070
written+=c.length;
7171
});
@@ -86,9 +86,9 @@ function streamWrite(alice, bob, message, encoding, writes) {
8686
}
8787

8888
functionlegacyWrite(alice,bob,message,encoding,writes){
89-
varwritten=0;
90-
varenc,dec;
91-
for(vari=0;i<writes;i++){
89+
letwritten=0;
90+
letenc,dec;
91+
for(leti=0;i<writes;i++){
9292
enc=alice.update(message,encoding);
9393
dec=bob.update(enc);
9494
written+=dec.length;

‎benchmark/crypto/get-ciphers.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const bench = common.createBenchmark(main, {
99

1010
functionmain({ n, v }){
1111
constmethod=require(v).getCiphers;
12-
vari=0;
12+
leti=0;
1313
// First call to getCiphers will dominate the results
1414
if(n>1){
1515
for(;i<n;i++)

‎benchmark/crypto/hash-stream-creation.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ function main({ api, type, len, out, writes, algo }) {
2020
api='legacy';
2121
}
2222

23-
varmessage;
24-
varencoding;
23+
letmessage;
24+
letencoding;
2525
switch(type){
2626
case'asc':
2727
message='a'.repeat(len);
@@ -52,7 +52,7 @@ function legacyWrite(algo, message, encoding, writes, len, outEnc) {
5252
while(writes-->0){
5353
consth=crypto.createHash(algo);
5454
h.update(message,encoding);
55-
varres=h.digest(outEnc);
55+
letres=h.digest(outEnc);
5656

5757
// Include buffer creation costs for older versions
5858
if(outEnc==='buffer'&&typeofres==='string')

‎benchmark/crypto/hash-stream-throughput.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ function main({ api, type, len, algo, writes }) {
1919
api='legacy';
2020
}
2121

22-
varmessage;
23-
varencoding;
22+
letmessage;
23+
letencoding;
2424
switch(type){
2525
case'asc':
2626
message='a'.repeat(len);

‎benchmark/crypto/rsa-encrypt-decrypt-throughput.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function StreamWrite(algo, keylen, message, n, len) {
3535

3636
constprivateKey=RSA_PrivatePem[keylen];
3737
constpublicKey=RSA_PublicPem[keylen];
38-
for(vari=0;i<n;i++){
38+
for(leti=0;i<n;i++){
3939
constenc=crypto.privateEncrypt(privateKey,message);
4040
crypto.publicDecrypt(publicKey,enc);
4141
}

0 commit comments

Comments
 (0)