2016-05-31 19:03:59 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const common = require('../common');
|
|
|
|
const Readable = require('stream').Readable;
|
|
|
|
|
|
|
|
const bench = common.createBenchmark(main, {
|
2017-05-19 10:07:53 +02:00
|
|
|
n: [200e1],
|
|
|
|
type: ['string', 'buffer']
|
2016-05-31 19:03:59 +02:00
|
|
|
});
|
|
|
|
|
2017-12-30 03:56:10 +01:00
|
|
|
function main({ n, type }) {
|
2016-05-31 19:03:59 +02:00
|
|
|
const s = new Readable();
|
2017-05-19 10:07:53 +02:00
|
|
|
var data = 'a'.repeat(32);
|
2017-12-30 03:56:10 +01:00
|
|
|
if (type === 'buffer')
|
2017-05-19 10:07:53 +02:00
|
|
|
data = Buffer.from(data);
|
|
|
|
s._read = function() {};
|
2016-05-31 19:03:59 +02:00
|
|
|
|
|
|
|
bench.start();
|
|
|
|
for (var k = 0; k < n; ++k) {
|
|
|
|
for (var i = 0; i < 1e4; ++i)
|
2017-05-19 10:07:53 +02:00
|
|
|
s.push(data);
|
2016-05-31 19:03:59 +02:00
|
|
|
while (s.read(32));
|
|
|
|
}
|
|
|
|
bench.end(n);
|
|
|
|
}
|