0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-29 07:00:59 +01:00
nodejs/benchmark/streams/creation.js
Daniele Belardi 4bf888d3d2
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>
2020-02-13 21:41:33 +01:00

57 lines
1.0 KiB
JavaScript

'use strict';
const common = require('../common.js');
const {
Duplex,
Readable,
Transform,
Writable,
} = require('stream');
const bench = common.createBenchmark(main, {
n: [50e6],
kind: ['duplex', 'readable', 'transform', 'writable']
});
function main({ n, kind }) {
switch (kind) {
case 'duplex':
new Duplex({});
new Duplex();
bench.start();
for (let i = 0; i < n; ++i)
new Duplex();
bench.end(n);
break;
case 'readable':
new Readable({});
new Readable();
bench.start();
for (let i = 0; i < n; ++i)
new Readable();
bench.end(n);
break;
case 'writable':
new Writable({});
new Writable();
bench.start();
for (let i = 0; i < n; ++i)
new Writable();
bench.end(n);
break;
case 'transform':
new Transform({});
new Transform();
bench.start();
for (let i = 0; i < n; ++i)
new Transform();
bench.end(n);
break;
default:
throw new Error('Invalid kind');
}
}