0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-29 07:00:59 +01:00

benchmark: (streams) use destructuring

PR-URL: https://github.com/nodejs/node/pull/18250
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Ruben Bridgewater 2017-12-30 03:56:10 +01:00
parent 5dc289b3f0
commit 592454e703
No known key found for this signature in database
GPG Key ID: F07496B3EB3C1762
7 changed files with 8 additions and 16 deletions

View File

@ -7,8 +7,7 @@ const bench = common.createBenchmark(main, {
n: [100e1]
});
function main(conf) {
const n = +conf.n;
function main({ n }) {
const b = new Buffer(32);
const s = new Readable();
function noop() {}

View File

@ -7,8 +7,7 @@ const bench = common.createBenchmark(main, {
n: [100e1]
});
function main(conf) {
const n = +conf.n;
function main({ n }) {
const b = new Buffer(32);
const s = new Readable();
function noop() {}

View File

@ -8,11 +8,10 @@ const bench = common.createBenchmark(main, {
type: ['string', 'buffer']
});
function main(conf) {
const n = +conf.n;
function main({ n, type }) {
const s = new Readable();
var data = 'a'.repeat(32);
if (conf.type === 'buffer')
if (type === 'buffer')
data = Buffer.from(data);
s._read = function() {};

View File

@ -7,8 +7,7 @@ const bench = common.createBenchmark(main, {
n: [50e2]
});
function main(conf) {
const n = +conf.n;
function main({ n }) {
const b = new Buffer(32);
const s = new Readable();
function noop() {}

View File

@ -7,8 +7,7 @@ const bench = common.createBenchmark(main, {
n: [100e1]
});
function main(conf) {
const n = +conf.n;
function main({ n }) {
const b = new Buffer(32);
const s = new Readable();
function noop() {}

View File

@ -13,9 +13,7 @@ function MyTransform() {
inherits(MyTransform, Transform);
MyTransform.prototype._transform = function() {};
function main(conf) {
const n = +conf.n;
function main({ n }) {
bench.start();
for (var i = 0; i < n; ++i)
new MyTransform();

View File

@ -7,8 +7,7 @@ const bench = common.createBenchmark(main, {
n: [2e6]
});
function main(conf) {
const n = +conf.n;
function main({ n }) {
const b = Buffer.allocUnsafe(1024);
const s = new Writable();
s._write = function(chunk, encoding, cb) {