11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common.js'); 31cb0ef41Sopenharmony_ciconst { 41cb0ef41Sopenharmony_ci Duplex, 51cb0ef41Sopenharmony_ci Readable, 61cb0ef41Sopenharmony_ci Transform, 71cb0ef41Sopenharmony_ci Writable, 81cb0ef41Sopenharmony_ci} = require('stream'); 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_ciconst bench = common.createBenchmark(main, { 111cb0ef41Sopenharmony_ci n: [50e6], 121cb0ef41Sopenharmony_ci kind: ['duplex', 'readable', 'transform', 'writable'], 131cb0ef41Sopenharmony_ci}); 141cb0ef41Sopenharmony_ci 151cb0ef41Sopenharmony_cifunction main({ n, kind }) { 161cb0ef41Sopenharmony_ci switch (kind) { 171cb0ef41Sopenharmony_ci case 'duplex': 181cb0ef41Sopenharmony_ci new Duplex({}); 191cb0ef41Sopenharmony_ci new Duplex(); 201cb0ef41Sopenharmony_ci 211cb0ef41Sopenharmony_ci bench.start(); 221cb0ef41Sopenharmony_ci for (let i = 0; i < n; ++i) 231cb0ef41Sopenharmony_ci new Duplex(); 241cb0ef41Sopenharmony_ci bench.end(n); 251cb0ef41Sopenharmony_ci break; 261cb0ef41Sopenharmony_ci case 'readable': 271cb0ef41Sopenharmony_ci new Readable({}); 281cb0ef41Sopenharmony_ci new Readable(); 291cb0ef41Sopenharmony_ci 301cb0ef41Sopenharmony_ci bench.start(); 311cb0ef41Sopenharmony_ci for (let i = 0; i < n; ++i) 321cb0ef41Sopenharmony_ci new Readable(); 331cb0ef41Sopenharmony_ci bench.end(n); 341cb0ef41Sopenharmony_ci break; 351cb0ef41Sopenharmony_ci case 'writable': 361cb0ef41Sopenharmony_ci new Writable({}); 371cb0ef41Sopenharmony_ci new Writable(); 381cb0ef41Sopenharmony_ci 391cb0ef41Sopenharmony_ci bench.start(); 401cb0ef41Sopenharmony_ci for (let i = 0; i < n; ++i) 411cb0ef41Sopenharmony_ci new Writable(); 421cb0ef41Sopenharmony_ci bench.end(n); 431cb0ef41Sopenharmony_ci break; 441cb0ef41Sopenharmony_ci case 'transform': 451cb0ef41Sopenharmony_ci new Transform({}); 461cb0ef41Sopenharmony_ci new Transform(); 471cb0ef41Sopenharmony_ci 481cb0ef41Sopenharmony_ci bench.start(); 491cb0ef41Sopenharmony_ci for (let i = 0; i < n; ++i) 501cb0ef41Sopenharmony_ci new Transform(); 511cb0ef41Sopenharmony_ci bench.end(n); 521cb0ef41Sopenharmony_ci break; 531cb0ef41Sopenharmony_ci default: 541cb0ef41Sopenharmony_ci throw new Error('Invalid kind'); 551cb0ef41Sopenharmony_ci } 561cb0ef41Sopenharmony_ci} 57