2016-05-31 19:03:59 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const common = require('../common');
|
|
|
|
const Readable = require('stream').Readable;
|
|
|
|
|
|
|
|
const bench = common.createBenchmark(main, {
|
2018-03-17 16:19:09 +01:00
|
|
|
n: [1e3]
|
2016-05-31 19:03:59 +02:00
|
|
|
});
|
|
|
|
|
2017-12-30 03:56:10 +01:00
|
|
|
function main({ n }) {
|
2018-02-24 17:52:14 +01:00
|
|
|
const b = Buffer.alloc(32);
|
2016-05-31 19:03:59 +02:00
|
|
|
const s = new Readable();
|
|
|
|
function noop() {}
|
|
|
|
s._read = noop;
|
|
|
|
|
|
|
|
bench.start();
|
2020-01-31 16:50:00 +01:00
|
|
|
for (let k = 0; k < n; ++k) {
|
|
|
|
for (let i = 0; i < 1e4; ++i)
|
2016-05-31 19:03:59 +02:00
|
|
|
s.push(b);
|
|
|
|
while (s.read(128));
|
|
|
|
}
|
|
|
|
bench.end(n);
|
|
|
|
}
|