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