diff --git a/benchmark/streams/pipe-object-mode.js b/benchmark/streams/pipe-object-mode.js new file mode 100644 index 00000000000000..d52b2238780ccb --- /dev/null +++ b/benchmark/streams/pipe-object-mode.js @@ -0,0 +1,24 @@ +'use strict'; + +const common = require('../common'); +const { Readable, Writable } = require('stream'); + +const bench = common.createBenchmark(main, { + n: [5e6] +}); + +function main({ n }) { + const b = {}; + const r = new Readable({ objectMode: true }); + const w = new Writable({ objectMode: true }); + + var i = 0; + + 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)); +} diff --git a/benchmark/streams/pipe.js b/benchmark/streams/pipe.js new file mode 100644 index 00000000000000..a7d67b7d6908c8 --- /dev/null +++ b/benchmark/streams/pipe.js @@ -0,0 +1,24 @@ +'use strict'; + +const common = require('../common'); +const { Readable, Writable } = require('stream'); + +const bench = common.createBenchmark(main, { + n: [5e6] +}); + +function main({ n }) { + const b = new Buffer(1024); + const r = new Readable(); + const w = new Writable(); + + var i = 0; + + 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)); +}