2018-02-06 21:48:54 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const common = require('../common');
|
|
|
|
const { Readable, Writable } = require('stream');
|
|
|
|
|
|
|
|
const bench = common.createBenchmark(main, {
|
2023-01-29 18:13:35 +00:00
|
|
|
n: [5e6],
|
2018-02-06 21:48:54 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
function main({ n }) {
|
2018-02-24 16:52:14 +00:00
|
|
|
const b = Buffer.alloc(1024);
|
2018-02-06 21:48:54 +00:00
|
|
|
const r = new Readable();
|
|
|
|
const w = new Writable();
|
|
|
|
|
2020-01-31 15:50:00 +00:00
|
|
|
let i = 0;
|
2018-02-06 21:48:54 +00:00
|
|
|
|
|
|
|
r._read = () => r.push(i++ === n ? null : b);
|
|
|
|
w._write = (data, enc, cb) => cb();
|
|
|
|
|
|
|
|
bench.start();
|
|
|
|
|
|
|
|
r.pipe(w);
|
|
|
|
w.on('finish', () => bench.end(n));
|
|
|
|
}
|