mirror of
https://github.com/nodejs/node.git
synced 2026-10-14 10:26:26 -04:00
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:
1 parent
d0ed431041
commit
4bf888d3d2
30 files changed
+75
-80
No files matched your search
@@ -37,14 +37,13 @@ function main({ ext, cache, files }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function measureDir(cache, files) {
|
function measureDir(cache, files) {
|
||||||
var i;
|
|
||||||
if (cache) {
|
if (cache) {
|
||||||
for (i = 0; i <= files; i++) {
|
for (let i = 0; i <= files; i++) {
|
||||||
require(`${benchmarkDirectory}/${i}`);
|
require(`${benchmarkDirectory}/${i}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bench.start();
|
bench.start();
|
||||||
for (i = 0; i <= files; i++) {
|
for (let i = 0; i <= files; i++) {
|
||||||
require(`${benchmarkDirectory}/${i}`);
|
require(`${benchmarkDirectory}/${i}`);
|
||||||
}
|
}
|
||||||
bench.end(files);
|
bench.end(files);
|
||||||
|
|||||||
@@ -42,15 +42,14 @@ function main({ n, name, cache, files, dir }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function measureDir(n, cache, files, name) {
|
function measureDir(n, cache, files, name) {
|
||||||
var i;
|
|
||||||
if (cache) {
|
if (cache) {
|
||||||
for (i = 0; i <= files; i++) {
|
for (let i = 0; i <= files; i++) {
|
||||||
require(`${benchmarkDirectory}${i}${name}`);
|
require(`${benchmarkDirectory}${i}${name}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bench.start();
|
bench.start();
|
||||||
for (i = 0; i <= files; i++) {
|
for (let i = 0; i <= files; i++) {
|
||||||
for (var j = 0; j < n; j++)
|
for (let j = 0; j < n; j++)
|
||||||
require(`${benchmarkDirectory}${i}${name}`);
|
require(`${benchmarkDirectory}${i}${name}`);
|
||||||
// Pretend mixed input (otherwise the results are less representative due to
|
// Pretend mixed input (otherwise the results are less representative due to
|
||||||
// highly specialized code).
|
// highly specialized code).
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ function main({ n, engine, type }) {
|
|||||||
const args = generateArgs(type);
|
const args = generateArgs(type);
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
for (var i = 0; i < n; i++) {
|
for (let i = 0; i < n; i++) {
|
||||||
fn.apply(null, args);
|
fn.apply(null, args);
|
||||||
}
|
}
|
||||||
bench.end(n);
|
bench.end(n);
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ try {
|
|||||||
}
|
}
|
||||||
const napi = napi_binding.hello;
|
const napi = napi_binding.hello;
|
||||||
|
|
||||||
var c = 0;
|
let c = 0;
|
||||||
function js() {
|
function js() {
|
||||||
return c++;
|
return c++;
|
||||||
}
|
}
|
||||||
@@ -44,7 +44,7 @@ const bench = common.createBenchmark(main, {
|
|||||||
function main({ n, type }) {
|
function main({ n, type }) {
|
||||||
const fn = type === 'cxx' ? cxx : type === 'napi' ? napi : js;
|
const fn = type === 'cxx' ? cxx : type === 'napi' ? napi : js;
|
||||||
bench.start();
|
bench.start();
|
||||||
for (var i = 0; i < n; i++) {
|
for (let i = 0; i < n; i++) {
|
||||||
fn();
|
fn();
|
||||||
}
|
}
|
||||||
bench.end(n);
|
bench.end(n);
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ const bench = common.createBenchmark(main, {
|
|||||||
dur: [5],
|
dur: [5],
|
||||||
});
|
});
|
||||||
|
|
||||||
var chunk;
|
let chunk;
|
||||||
var encoding;
|
let encoding;
|
||||||
|
|
||||||
function main({ dur, len, type }) {
|
function main({ dur, len, type }) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ const bench = common.createBenchmark(main, {
|
|||||||
dur: [5],
|
dur: [5],
|
||||||
});
|
});
|
||||||
|
|
||||||
var chunk;
|
let chunk;
|
||||||
var encoding;
|
let encoding;
|
||||||
|
|
||||||
function main({ dur, len, type }) {
|
function main({ dur, len, type }) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ const bench = common.createBenchmark(main, {
|
|||||||
dur: [5],
|
dur: [5],
|
||||||
});
|
});
|
||||||
|
|
||||||
var chunk;
|
let chunk;
|
||||||
var encoding;
|
let encoding;
|
||||||
|
|
||||||
function main({ dur, len, type }) {
|
function main({ dur, len, type }) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
|||||||
@@ -12,10 +12,10 @@ const bench = common.createBenchmark(main, {
|
|||||||
dur: [5]
|
dur: [5]
|
||||||
});
|
});
|
||||||
|
|
||||||
var chunk;
|
let chunk;
|
||||||
var encoding;
|
let encoding;
|
||||||
var recvbuf;
|
let recvbuf;
|
||||||
var received = 0;
|
let received = 0;
|
||||||
|
|
||||||
function main({ dur, sendchunklen, type, recvbuflen, recvbufgenfn }) {
|
function main({ dur, sendchunklen, type, recvbuflen, recvbufgenfn }) {
|
||||||
if (isFinite(recvbuflen) && recvbuflen > 0)
|
if (isFinite(recvbuflen) && recvbuflen > 0)
|
||||||
@@ -38,8 +38,8 @@ function main({ dur, sendchunklen, type, recvbuflen, recvbufgenfn }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const reader = new Reader();
|
const reader = new Reader();
|
||||||
var writer;
|
let writer;
|
||||||
var socketOpts;
|
let socketOpts;
|
||||||
if (recvbuf === undefined) {
|
if (recvbuf === undefined) {
|
||||||
writer = new Writer();
|
writer = new Writer();
|
||||||
socketOpts = { port: PORT };
|
socketOpts = { port: PORT };
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ const bench = common.createBenchmark(main, {
|
|||||||
flags: ['--expose-internals']
|
flags: ['--expose-internals']
|
||||||
});
|
});
|
||||||
|
|
||||||
var chunk;
|
let chunk;
|
||||||
var encoding;
|
let encoding;
|
||||||
|
|
||||||
function main({ dur, len, type }) {
|
function main({ dur, len, type }) {
|
||||||
// Can only require internals inside main().
|
// Can only require internals inside main().
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ function main({ dur, len, type }) {
|
|||||||
const PORT = common.PORT;
|
const PORT = common.PORT;
|
||||||
|
|
||||||
const serverHandle = new TCP(TCPConstants.SERVER);
|
const serverHandle = new TCP(TCPConstants.SERVER);
|
||||||
var err = serverHandle.bind('127.0.0.1', PORT);
|
let err = serverHandle.bind('127.0.0.1', PORT);
|
||||||
if (err)
|
if (err)
|
||||||
fail(err, 'bind');
|
fail(err, 'bind');
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ function main({ dur, len, type }) {
|
|||||||
|
|
||||||
// The meat of the benchmark is right here:
|
// The meat of the benchmark is right here:
|
||||||
bench.start();
|
bench.start();
|
||||||
var bytes = 0;
|
let bytes = 0;
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
// report in Gb/sec
|
// report in Gb/sec
|
||||||
@@ -67,7 +67,7 @@ function main({ dur, len, type }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function client(type, len) {
|
function client(type, len) {
|
||||||
var chunk;
|
let chunk;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'buf':
|
case 'buf':
|
||||||
chunk = Buffer.alloc(len, 'x');
|
chunk = Buffer.alloc(len, 'x');
|
||||||
@@ -102,7 +102,7 @@ function main({ dur, len, type }) {
|
|||||||
function write() {
|
function write() {
|
||||||
const writeReq = new WriteWrap();
|
const writeReq = new WriteWrap();
|
||||||
writeReq.oncomplete = afterWrite;
|
writeReq.oncomplete = afterWrite;
|
||||||
var err;
|
let err;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'buf':
|
case 'buf':
|
||||||
err = clientHandle.writeBuffer(writeReq, chunk);
|
err = clientHandle.writeBuffer(writeReq, chunk);
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ function main({ dur, len, type }) {
|
|||||||
|
|
||||||
// Server
|
// Server
|
||||||
const serverHandle = new TCP(TCPConstants.SERVER);
|
const serverHandle = new TCP(TCPConstants.SERVER);
|
||||||
var err = serverHandle.bind('127.0.0.1', PORT);
|
let err = serverHandle.bind('127.0.0.1', PORT);
|
||||||
if (err)
|
if (err)
|
||||||
fail(err, 'bind');
|
fail(err, 'bind');
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ function main({ dur, len, type }) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Client
|
// Client
|
||||||
var chunk;
|
let chunk;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'buf':
|
case 'buf':
|
||||||
chunk = Buffer.alloc(len, 'x');
|
chunk = Buffer.alloc(len, 'x');
|
||||||
@@ -83,7 +83,7 @@ function main({ dur, len, type }) {
|
|||||||
|
|
||||||
const clientHandle = new TCP(TCPConstants.SOCKET);
|
const clientHandle = new TCP(TCPConstants.SOCKET);
|
||||||
const connectReq = new TCPConnectWrap();
|
const connectReq = new TCPConnectWrap();
|
||||||
var bytes = 0;
|
let bytes = 0;
|
||||||
|
|
||||||
err = clientHandle.connect(connectReq, '127.0.0.1', PORT);
|
err = clientHandle.connect(connectReq, '127.0.0.1', PORT);
|
||||||
if (err)
|
if (err)
|
||||||
@@ -118,7 +118,7 @@ function main({ dur, len, type }) {
|
|||||||
function write() {
|
function write() {
|
||||||
const writeReq = new WriteWrap();
|
const writeReq = new WriteWrap();
|
||||||
writeReq.oncomplete = afterWrite;
|
writeReq.oncomplete = afterWrite;
|
||||||
var err;
|
let err;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'buf':
|
case 'buf':
|
||||||
err = clientHandle.writeBuffer(writeReq, chunk);
|
err = clientHandle.writeBuffer(writeReq, chunk);
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ function main({ dur, len, type }) {
|
|||||||
const PORT = common.PORT;
|
const PORT = common.PORT;
|
||||||
|
|
||||||
const serverHandle = new TCP(TCPConstants.SERVER);
|
const serverHandle = new TCP(TCPConstants.SERVER);
|
||||||
var err = serverHandle.bind('127.0.0.1', PORT);
|
let err = serverHandle.bind('127.0.0.1', PORT);
|
||||||
if (err)
|
if (err)
|
||||||
fail(err, 'bind');
|
fail(err, 'bind');
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ function main({ dur, len, type }) {
|
|||||||
if (err)
|
if (err)
|
||||||
fail(err, 'connect');
|
fail(err, 'connect');
|
||||||
|
|
||||||
var chunk;
|
let chunk;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'buf':
|
case 'buf':
|
||||||
chunk = Buffer.alloc(len, 'x');
|
chunk = Buffer.alloc(len, 'x');
|
||||||
@@ -62,7 +62,7 @@ function main({ dur, len, type }) {
|
|||||||
const writeReq = new WriteWrap();
|
const writeReq = new WriteWrap();
|
||||||
writeReq.async = false;
|
writeReq.async = false;
|
||||||
writeReq.oncomplete = afterWrite;
|
writeReq.oncomplete = afterWrite;
|
||||||
var err;
|
let err;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'buf':
|
case 'buf':
|
||||||
err = clientHandle.writeBuffer(writeReq, chunk);
|
err = clientHandle.writeBuffer(writeReq, chunk);
|
||||||
@@ -108,7 +108,7 @@ function main({ dur, len, type }) {
|
|||||||
fail(err, 'connect');
|
fail(err, 'connect');
|
||||||
|
|
||||||
connectReq.oncomplete = function() {
|
connectReq.oncomplete = function() {
|
||||||
var bytes = 0;
|
let bytes = 0;
|
||||||
clientHandle.onread = function(buffer) {
|
clientHandle.onread = function(buffer) {
|
||||||
// We're not expecting to ever get an EOF from the client.
|
// We're not expecting to ever get an EOF from the client.
|
||||||
// Just lots of data forever.
|
// Just lots of data forever.
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ const bench = common.createBenchmark(main, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function main({ n, pathext }) {
|
function main({ n, pathext }) {
|
||||||
var ext;
|
let ext;
|
||||||
const extIdx = pathext.indexOf('|');
|
const extIdx = pathext.indexOf('|');
|
||||||
if (extIdx !== -1) {
|
if (extIdx !== -1) {
|
||||||
ext = pathext.slice(extIdx + 1);
|
ext = pathext.slice(extIdx + 1);
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ const bench = common.createBenchmark(main, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function main({ n, pathext }) {
|
function main({ n, pathext }) {
|
||||||
var ext;
|
let ext;
|
||||||
const extIdx = pathext.indexOf('|');
|
const extIdx = pathext.indexOf('|');
|
||||||
if (extIdx !== -1) {
|
if (extIdx !== -1) {
|
||||||
ext = pathext.slice(extIdx + 1);
|
ext = pathext.slice(extIdx + 1);
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ const bench = common.createBenchmark(main, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function main({ n, paths }) {
|
function main({ n, paths }) {
|
||||||
var to = '';
|
let to = '';
|
||||||
const delimIdx = paths.indexOf('|');
|
const delimIdx = paths.indexOf('|');
|
||||||
if (delimIdx > -1) {
|
if (delimIdx > -1) {
|
||||||
to = paths.slice(delimIdx + 1);
|
to = paths.slice(delimIdx + 1);
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ const bench = common.createBenchmark(main, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function main({ n, paths }) {
|
function main({ n, paths }) {
|
||||||
var to = '';
|
let to = '';
|
||||||
const delimIdx = paths.indexOf('|');
|
const delimIdx = paths.indexOf('|');
|
||||||
if (delimIdx > -1) {
|
if (delimIdx > -1) {
|
||||||
to = paths.slice(delimIdx + 1);
|
to = paths.slice(delimIdx + 1);
|
||||||
|
|||||||
@@ -10,27 +10,26 @@ const bench = common.createBenchmark(main, {
|
|||||||
|
|
||||||
function main({ n, type }) {
|
function main({ n, type }) {
|
||||||
const hrtime = process.hrtime;
|
const hrtime = process.hrtime;
|
||||||
var noDead = type === 'bigint' ? hrtime.bigint() : hrtime();
|
let noDead = type === 'bigint' ? hrtime.bigint() : hrtime();
|
||||||
var i;
|
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'raw':
|
case 'raw':
|
||||||
bench.start();
|
bench.start();
|
||||||
for (i = 0; i < n; i++) {
|
for (let i = 0; i < n; i++) {
|
||||||
noDead = hrtime();
|
noDead = hrtime();
|
||||||
}
|
}
|
||||||
bench.end(n);
|
bench.end(n);
|
||||||
break;
|
break;
|
||||||
case 'diff':
|
case 'diff':
|
||||||
bench.start();
|
bench.start();
|
||||||
for (i = 0; i < n; i++) {
|
for (let i = 0; i < n; i++) {
|
||||||
noDead = hrtime(noDead);
|
noDead = hrtime(noDead);
|
||||||
}
|
}
|
||||||
bench.end(n);
|
bench.end(n);
|
||||||
break;
|
break;
|
||||||
case 'bigint':
|
case 'bigint':
|
||||||
bench.start();
|
bench.start();
|
||||||
for (i = 0; i < n; i++) {
|
for (let i = 0; i < n; i++) {
|
||||||
noDead = hrtime.bigint();
|
noDead = hrtime.bigint();
|
||||||
}
|
}
|
||||||
bench.end(n);
|
bench.end(n);
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ const bench = common.createBenchmark(main, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function main({ n }) {
|
function main({ n }) {
|
||||||
var j = 0;
|
let j = 0;
|
||||||
|
|
||||||
function cb1(arg1) {
|
function cb1(arg1) {
|
||||||
j++;
|
j++;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ const bench = common.createBenchmark(main, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function main({ n }) {
|
function main({ n }) {
|
||||||
var j = 0;
|
let j = 0;
|
||||||
|
|
||||||
function cb() {
|
function cb() {
|
||||||
j++;
|
j++;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ const bench = common.createBenchmark(main, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function main({ n }) {
|
function main({ n }) {
|
||||||
var j = 0;
|
let j = 0;
|
||||||
|
|
||||||
function cb() {
|
function cb() {
|
||||||
j++;
|
j++;
|
||||||
|
|||||||
@@ -10,23 +10,23 @@ const bench = common.createBenchmark(main, {
|
|||||||
|
|
||||||
function main({ type, n }) {
|
function main({ type, n }) {
|
||||||
const input = inputs[type];
|
const input = inputs[type];
|
||||||
var i;
|
|
||||||
// Execute the function a "sufficient" number of times before the timed
|
// Execute the function a "sufficient" number of times before the timed
|
||||||
// loop to ensure the function is optimized just once.
|
// loop to ensure the function is optimized just once.
|
||||||
if (type === 'multicharsep') {
|
if (type === 'multicharsep') {
|
||||||
for (i = 0; i < n; i += 1)
|
for (let i = 0; i < n; i += 1)
|
||||||
querystring.parse(input, '&&&&&&&&&&');
|
querystring.parse(input, '&&&&&&&&&&');
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
for (i = 0; i < n; i += 1)
|
for (let i = 0; i < n; i += 1)
|
||||||
querystring.parse(input, '&&&&&&&&&&');
|
querystring.parse(input, '&&&&&&&&&&');
|
||||||
bench.end(n);
|
bench.end(n);
|
||||||
} else {
|
} else {
|
||||||
for (i = 0; i < n; i += 1)
|
for (let i = 0; i < n; i += 1)
|
||||||
querystring.parse(input);
|
querystring.parse(input);
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
for (i = 0; i < n; i += 1)
|
for (let i = 0; i < n; i += 1)
|
||||||
querystring.parse(input);
|
querystring.parse(input);
|
||||||
bench.end(n);
|
bench.end(n);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,14 +13,13 @@ const bench = common.createBenchmark(main, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function main({ n, kind }) {
|
function main({ n, kind }) {
|
||||||
var i = 0;
|
|
||||||
switch (kind) {
|
switch (kind) {
|
||||||
case 'duplex':
|
case 'duplex':
|
||||||
new Duplex({});
|
new Duplex({});
|
||||||
new Duplex();
|
new Duplex();
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
for (; i < n; ++i)
|
for (let i = 0; i < n; ++i)
|
||||||
new Duplex();
|
new Duplex();
|
||||||
bench.end(n);
|
bench.end(n);
|
||||||
break;
|
break;
|
||||||
@@ -29,7 +28,7 @@ function main({ n, kind }) {
|
|||||||
new Readable();
|
new Readable();
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
for (; i < n; ++i)
|
for (let i = 0; i < n; ++i)
|
||||||
new Readable();
|
new Readable();
|
||||||
bench.end(n);
|
bench.end(n);
|
||||||
break;
|
break;
|
||||||
@@ -38,7 +37,7 @@ function main({ n, kind }) {
|
|||||||
new Writable();
|
new Writable();
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
for (; i < n; ++i)
|
for (let i = 0; i < n; ++i)
|
||||||
new Writable();
|
new Writable();
|
||||||
bench.end(n);
|
bench.end(n);
|
||||||
break;
|
break;
|
||||||
@@ -47,7 +46,7 @@ function main({ n, kind }) {
|
|||||||
new Transform();
|
new Transform();
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
for (; i < n; ++i)
|
for (let i = 0; i < n; ++i)
|
||||||
new Transform();
|
new Transform();
|
||||||
bench.end(n);
|
bench.end(n);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ function main({ n }) {
|
|||||||
const r = new Readable({ objectMode: true });
|
const r = new Readable({ objectMode: true });
|
||||||
const w = new Writable({ objectMode: true });
|
const w = new Writable({ objectMode: true });
|
||||||
|
|
||||||
var i = 0;
|
let i = 0;
|
||||||
|
|
||||||
r._read = () => r.push(i++ === n ? null : b);
|
r._read = () => r.push(i++ === n ? null : b);
|
||||||
w._write = (data, enc, cb) => cb();
|
w._write = (data, enc, cb) => cb();
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ function main({ n }) {
|
|||||||
const r = new Readable();
|
const r = new Readable();
|
||||||
const w = new Writable();
|
const w = new Writable();
|
||||||
|
|
||||||
var i = 0;
|
let i = 0;
|
||||||
|
|
||||||
r._read = () => r.push(i++ === n ? null : b);
|
r._read = () => r.push(i++ === n ? null : b);
|
||||||
w._write = (data, enc, cb) => cb();
|
w._write = (data, enc, cb) => cb();
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ function main({ n }) {
|
|||||||
s._read = noop;
|
s._read = noop;
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
for (var k = 0; k < n; ++k) {
|
for (let k = 0; k < n; ++k) {
|
||||||
for (var i = 0; i < 1e4; ++i)
|
for (let i = 0; i < 1e4; ++i)
|
||||||
s.push(b);
|
s.push(b);
|
||||||
while (s.read(128));
|
while (s.read(128));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ function main({ n }) {
|
|||||||
s._read = noop;
|
s._read = noop;
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
for (var k = 0; k < n; ++k) {
|
for (let k = 0; k < n; ++k) {
|
||||||
for (var i = 0; i < 1e4; ++i)
|
for (let i = 0; i < 1e4; ++i)
|
||||||
s.push(b);
|
s.push(b);
|
||||||
while (s.read(106));
|
while (s.read(106));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,14 +10,14 @@ const bench = common.createBenchmark(main, {
|
|||||||
|
|
||||||
function main({ n, type }) {
|
function main({ n, type }) {
|
||||||
const s = new Readable();
|
const s = new Readable();
|
||||||
var data = 'a'.repeat(32);
|
let data = 'a'.repeat(32);
|
||||||
if (type === 'buffer')
|
if (type === 'buffer')
|
||||||
data = Buffer.from(data);
|
data = Buffer.from(data);
|
||||||
s._read = function() {};
|
s._read = function() {};
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
for (var k = 0; k < n; ++k) {
|
for (let k = 0; k < n; ++k) {
|
||||||
for (var i = 0; i < 1e4; ++i)
|
for (let i = 0; i < 1e4; ++i)
|
||||||
s.push(data);
|
s.push(data);
|
||||||
while (s.read(32));
|
while (s.read(32));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ function main({ n }) {
|
|||||||
s._read = noop;
|
s._read = noop;
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
for (var k = 0; k < n; ++k) {
|
for (let k = 0; k < n; ++k) {
|
||||||
for (var i = 0; i < 1e4; ++i)
|
for (let i = 0; i < 1e4; ++i)
|
||||||
s.push(b);
|
s.push(b);
|
||||||
while (s.read());
|
while (s.read());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ function main({ n }) {
|
|||||||
s._read = noop;
|
s._read = noop;
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
for (var k = 0; k < n; ++k) {
|
for (let k = 0; k < n; ++k) {
|
||||||
for (var i = 0; i < 1e4; ++i)
|
for (let i = 0; i < 1e4; ++i)
|
||||||
s.push(b);
|
s.push(b);
|
||||||
while (s.read(12));
|
while (s.read(12));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,12 +14,11 @@ const ASC_ALPHA = 'Blueberry jam';
|
|||||||
const UTF16_BUF = Buffer.from('Blåbærsyltetøy', 'utf16le');
|
const UTF16_BUF = Buffer.from('Blåbærsyltetøy', 'utf16le');
|
||||||
|
|
||||||
function main({ encoding, inLen, chunkLen, n }) {
|
function main({ encoding, inLen, chunkLen, n }) {
|
||||||
var alpha;
|
let alpha;
|
||||||
var buf;
|
let buf;
|
||||||
const chunks = [];
|
const chunks = [];
|
||||||
var str = '';
|
let str = '';
|
||||||
const isBase64 = (encoding === 'base64-ascii' || encoding === 'base64-utf8');
|
const isBase64 = (encoding === 'base64-ascii' || encoding === 'base64-utf8');
|
||||||
var i;
|
|
||||||
|
|
||||||
if (encoding === 'ascii' || encoding === 'base64-ascii')
|
if (encoding === 'ascii' || encoding === 'base64-ascii')
|
||||||
alpha = ASC_ALPHA;
|
alpha = ASC_ALPHA;
|
||||||
@@ -33,7 +32,7 @@ function main({ encoding, inLen, chunkLen, n }) {
|
|||||||
|
|
||||||
const sd = new StringDecoder(isBase64 ? 'base64' : encoding);
|
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 (i > 0 && (i % chunkLen) === 0 && !isBase64) {
|
||||||
if (alpha) {
|
if (alpha) {
|
||||||
chunks.push(Buffer.from(str, encoding));
|
chunks.push(Buffer.from(str, encoding));
|
||||||
@@ -46,8 +45,8 @@ function main({ encoding, inLen, chunkLen, n }) {
|
|||||||
if (alpha)
|
if (alpha)
|
||||||
str += alpha[i % alpha.length];
|
str += alpha[i % alpha.length];
|
||||||
else {
|
else {
|
||||||
var start = i;
|
let start = i;
|
||||||
var end = i + 2;
|
let end = i + 2;
|
||||||
if (i % 2 !== 0) {
|
if (i % 2 !== 0) {
|
||||||
++start;
|
++start;
|
||||||
++end;
|
++end;
|
||||||
@@ -77,8 +76,8 @@ function main({ encoding, inLen, chunkLen, n }) {
|
|||||||
const nChunks = chunks.length;
|
const nChunks = chunks.length;
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
for (i = 0; i < n; ++i) {
|
for (let i = 0; i < n; ++i) {
|
||||||
for (var j = 0; j < nChunks; ++j)
|
for (let j = 0; j < nChunks; ++j)
|
||||||
sd.write(chunks[j]);
|
sd.write(chunks[j]);
|
||||||
}
|
}
|
||||||
bench.end(n);
|
bench.end(n);
|
||||||
|
|||||||
Reference in new issue
Block a user