11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst common = require('../common'); 41cb0ef41Sopenharmony_ciconst Readable = require('stream').Readable; 51cb0ef41Sopenharmony_ci 61cb0ef41Sopenharmony_ciconst bench = common.createBenchmark(main, { 71cb0ef41Sopenharmony_ci n: [200e1], 81cb0ef41Sopenharmony_ci type: ['string', 'buffer'], 91cb0ef41Sopenharmony_ci}); 101cb0ef41Sopenharmony_ci 111cb0ef41Sopenharmony_cifunction main({ n, type }) { 121cb0ef41Sopenharmony_ci const s = new Readable(); 131cb0ef41Sopenharmony_ci let data = 'a'.repeat(32); 141cb0ef41Sopenharmony_ci if (type === 'buffer') 151cb0ef41Sopenharmony_ci data = Buffer.from(data); 161cb0ef41Sopenharmony_ci s._read = function() {}; 171cb0ef41Sopenharmony_ci 181cb0ef41Sopenharmony_ci bench.start(); 191cb0ef41Sopenharmony_ci for (let k = 0; k < n; ++k) { 201cb0ef41Sopenharmony_ci for (let i = 0; i < 1e4; ++i) 211cb0ef41Sopenharmony_ci s.push(data); 221cb0ef41Sopenharmony_ci while (s.read(32)); 231cb0ef41Sopenharmony_ci } 241cb0ef41Sopenharmony_ci bench.end(n); 251cb0ef41Sopenharmony_ci} 26