2018-02-06 22:48:54 +01:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const common = require('../common');
|
|
|
|
const { Readable, Writable } = require('stream');
|
|
|
|
|
|
|
|
const bench = common.createBenchmark(main, {
|
2023-01-29 19:13:35 +01:00
|
|
|
n: [5e6],
|
2018-02-06 22:48:54 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
function main({ n }) {
|
|
|
|
const b = {};
|
|
|
|
const r = new Readable({ objectMode: true });
|
|
|
|
const w = new Writable({ objectMode: true });
|
|
|
|
|
2020-01-31 16:50:00 +01:00
|
|
|
let i = 0;
|
2018-02-06 22:48:54 +01: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));
|
|
|
|
}
|