11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst common = require('../common'); 41cb0ef41Sopenharmony_ciconst { Readable, Writable } = require('stream'); 51cb0ef41Sopenharmony_ci 61cb0ef41Sopenharmony_ciconst bench = common.createBenchmark(main, { 71cb0ef41Sopenharmony_ci n: [5e6], 81cb0ef41Sopenharmony_ci}); 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_cifunction main({ n }) { 111cb0ef41Sopenharmony_ci const b = Buffer.alloc(1024); 121cb0ef41Sopenharmony_ci const r = new Readable(); 131cb0ef41Sopenharmony_ci const w = new Writable(); 141cb0ef41Sopenharmony_ci 151cb0ef41Sopenharmony_ci let i = 0; 161cb0ef41Sopenharmony_ci 171cb0ef41Sopenharmony_ci r._read = () => r.push(i++ === n ? null : b); 181cb0ef41Sopenharmony_ci w._write = (data, enc, cb) => cb(); 191cb0ef41Sopenharmony_ci 201cb0ef41Sopenharmony_ci bench.start(); 211cb0ef41Sopenharmony_ci 221cb0ef41Sopenharmony_ci r.pipe(w); 231cb0ef41Sopenharmony_ci w.on('finish', () => bench.end(n)); 241cb0ef41Sopenharmony_ci} 25