11'use strict' ;
22
33const common = require ( '../common' ) ;
4- const { Readable, Writable, Duplex, finished } = require ( 'stream' ) ;
4+ const { Readable, Writable } = require ( 'stream' ) ;
5+ const { finished } = require ( 'stream/promises' ) ;
56
67const bench = common . createBenchmark ( main , {
78 n : [ 1e5 ] ,
8- streamType : [ 'readable' , 'writable' , 'duplex' ] ,
9+ streamType : [ 'readable' , 'writable' ] ,
910} ) ;
1011
11- function main ( { n, streamType } ) {
12+ async function main ( { n, streamType } ) {
1213 bench . start ( ) ;
1314
1415 for ( let i = 0 ; i < n ; i ++ ) {
@@ -17,21 +18,15 @@ function main({ n, streamType }) {
1718 switch ( streamType ) {
1819 case 'readable' :
1920 stream = new Readable ( { read ( ) { this . push ( null ) ; } } ) ;
21+ stream . resume ( ) ;
2022 break ;
2123 case 'writable' :
2224 stream = new Writable ( { write ( chunk , enc , cb ) { cb ( ) ; } } ) ;
2325 stream . end ( ) ;
2426 break ;
25- case 'duplex' :
26- stream = new Duplex ( {
27- read ( ) { this . push ( null ) ; } ,
28- write ( chunk , enc , cb ) { cb ( ) ; } ,
29- } ) ;
30- stream . end ( ) ;
31- break ;
3227 }
3328
34- finished ( stream , ( ) => { } ) ;
29+ await finished ( stream ) ;
3530 }
3631
3732 bench . end ( n ) ;
0 commit comments