• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3const common = require('../common');
4const { Readable, Writable } = require('stream');
5
6const bench = common.createBenchmark(main, {
7  n: [5e6]
8});
9
10function main({ n }) {
11  const b = Buffer.alloc(1024);
12  const r = new Readable();
13  const w = new Writable();
14
15  let i = 0;
16
17  r._read = () => r.push(i++ === n ? null : b);
18  w._write = (data, enc, cb) => cb();
19
20  bench.start();
21
22  r.pipe(w);
23  w.on('finish', () => bench.end(n));
24}
25