benchmark: use let instead of var in crypto

PR-URL: https://github.com/nodejs/node/pull/31135
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
dnlup 2019-12-30 12:20:07 +01:00 committed by Rich Trott
parent c052113238
commit 7365000e67
6 changed files with 14 additions and 14 deletions

View File

@ -25,7 +25,7 @@ function AEAD_Bench(cipher, message, associate_data, key, iv, n, len) {
const bits = written * 8;
const mbits = bits / (1024 * 1024);
for (var i = 0; i < n; i++) {
for (let i = 0; i < n; i++) {
const alice = crypto.createCipheriv(cipher, key, iv);
alice.setAAD(associate_data);
const enc = alice.update(message);

View File

@ -38,8 +38,8 @@ function main({ api, cipher, type, len, writes }) {
const alice_cipher = crypto.createCipher(cipher, alice_secret);
const bob_cipher = crypto.createDecipher(cipher, bob_secret);
var message;
var encoding;
let message;
let encoding;
switch (type) {
case 'asc':
message = 'a'.repeat(len);
@ -65,7 +65,7 @@ function main({ api, cipher, type, len, writes }) {
}
function streamWrite(alice, bob, message, encoding, writes) {
var written = 0;
let written = 0;
bob.on('data', (c) => {
written += c.length;
});
@ -86,9 +86,9 @@ function streamWrite(alice, bob, message, encoding, writes) {
}
function legacyWrite(alice, bob, message, encoding, writes) {
var written = 0;
var enc, dec;
for (var i = 0; i < writes; i++) {
let written = 0;
let enc, dec;
for (let i = 0; i < writes; i++) {
enc = alice.update(message, encoding);
dec = bob.update(enc);
written += dec.length;

View File

@ -9,7 +9,7 @@ const bench = common.createBenchmark(main, {
function main({ n, v }) {
const method = require(v).getCiphers;
var i = 0;
let i = 0;
// First call to getCiphers will dominate the results
if (n > 1) {
for (; i < n; i++)

View File

@ -20,8 +20,8 @@ function main({ api, type, len, out, writes, algo }) {
api = 'legacy';
}
var message;
var encoding;
let message;
let encoding;
switch (type) {
case 'asc':
message = 'a'.repeat(len);
@ -52,7 +52,7 @@ function legacyWrite(algo, message, encoding, writes, len, outEnc) {
while (writes-- > 0) {
const h = crypto.createHash(algo);
h.update(message, encoding);
var res = h.digest(outEnc);
let res = h.digest(outEnc);
// Include buffer creation costs for older versions
if (outEnc === 'buffer' && typeof res === 'string')

View File

@ -19,8 +19,8 @@ function main({ api, type, len, algo, writes }) {
api = 'legacy';
}
var message;
var encoding;
let message;
let encoding;
switch (type) {
case 'asc':
message = 'a'.repeat(len);

View File

@ -35,7 +35,7 @@ function StreamWrite(algo, keylen, message, n, len) {
const privateKey = RSA_PrivatePem[keylen];
const publicKey = RSA_PublicPem[keylen];
for (var i = 0; i < n; i++) {
for (let i = 0; i < n; i++) {
const enc = crypto.privateEncrypt(privateKey, message);
crypto.publicDecrypt(publicKey, enc);
}