benchmark: use let instead of var

Use `let` in module, napi, net, os, path, process, querystring, streams
and string_decoder.

PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
Daniele Belardi
2020-01-31 16:50:00 +01:00
committed by Anna Henningsen
parent d0ed431041
commit 4bf888d3d2
30 changed files with 75 additions and 80 deletions

View File

@@ -14,12 +14,11 @@ const ASC_ALPHA = 'Blueberry jam';
const UTF16_BUF = Buffer.from('Blåbærsyltetøy', 'utf16le');
function main({ encoding, inLen, chunkLen, n }) {
var alpha;
var buf;
let alpha;
let buf;
const chunks = [];
var str = '';
let str = '';
const isBase64 = (encoding === 'base64-ascii' || encoding === 'base64-utf8');
var i;
if (encoding === 'ascii' || encoding === 'base64-ascii')
alpha = ASC_ALPHA;
@@ -33,7 +32,7 @@ function main({ encoding, inLen, chunkLen, n }) {
const sd = new StringDecoder(isBase64 ? 'base64' : encoding);
for (i = 0; i < inLen; ++i) {
for (let i = 0; i < inLen; ++i) {
if (i > 0 && (i % chunkLen) === 0 && !isBase64) {
if (alpha) {
chunks.push(Buffer.from(str, encoding));
@@ -46,8 +45,8 @@ function main({ encoding, inLen, chunkLen, n }) {
if (alpha)
str += alpha[i % alpha.length];
else {
var start = i;
var end = i + 2;
let start = i;
let end = i + 2;
if (i % 2 !== 0) {
++start;
++end;
@@ -77,8 +76,8 @@ function main({ encoding, inLen, chunkLen, n }) {
const nChunks = chunks.length;
bench.start();
for (i = 0; i < n; ++i) {
for (var j = 0; j < nChunks; ++j)
for (let i = 0; i < n; ++i) {
for (let j = 0; j < nChunks; ++j)
sd.write(chunks[j]);
}
bench.end(n);