1'use strict'; 2 3const common = require('../common'); 4const Readable = require('stream').Readable; 5 6const bench = common.createBenchmark(main, { 7 n: [200e1], 8 type: ['string', 'buffer'] 9}); 10 11function main({ n, type }) { 12 const s = new Readable(); 13 let data = 'a'.repeat(32); 14 if (type === 'buffer') 15 data = Buffer.from(data); 16 s._read = function() {}; 17 18 bench.start(); 19 for (let k = 0; k < n; ++k) { 20 for (let i = 0; i < 1e4; ++i) 21 s.push(data); 22 while (s.read(32)); 23 } 24 bench.end(n); 25} 26