Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

benchmark: use let instead of var in crypto #31135

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion benchmark/crypto/aes-gcm-throughput.js
Expand Up @@ -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);
Expand Down
12 changes: 6 additions & 6 deletions benchmark/crypto/cipher-stream.js
Expand Up @@ -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);
Expand All @@ -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;
});
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion benchmark/crypto/get-ciphers.js
Expand Up @@ -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++)
Expand Down
6 changes: 3 additions & 3 deletions benchmark/crypto/hash-stream-creation.js
Expand Up @@ -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);
Expand Down Expand Up @@ -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')
Expand Down
4 changes: 2 additions & 2 deletions benchmark/crypto/hash-stream-throughput.js
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion benchmark/crypto/rsa-encrypt-decrypt-throughput.js
Expand Up @@ -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);
}
Expand Down