File tree 2 files changed +48
-0
lines changed
2 files changed +48
-0
lines changed Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+
3
+ const common = require ( '../common' ) ;
4
+ const { Readable, Writable } = require ( 'stream' ) ;
5
+
6
+ const bench = common . createBenchmark ( main , {
7
+ n : [ 5e6 ]
8
+ } ) ;
9
+
10
+ function main ( { n } ) {
11
+ const b = { } ;
12
+ const r = new Readable ( { objectMode : true } ) ;
13
+ const w = new Writable ( { objectMode : true } ) ;
14
+
15
+ var i = 0 ;
16
+
17
+ r . _read = ( ) => r . push ( i ++ === n ? null : b ) ;
18
+ w . _write = ( data , enc , cb ) => cb ( ) ;
19
+
20
+ bench . start ( ) ;
21
+
22
+ r . pipe ( w ) ;
23
+ w . on ( 'finish' , ( ) => bench . end ( n ) ) ;
24
+ }
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+
3
+ const common = require ( '../common' ) ;
4
+ const { Readable, Writable } = require ( 'stream' ) ;
5
+
6
+ const bench = common . createBenchmark ( main , {
7
+ n : [ 5e6 ]
8
+ } ) ;
9
+
10
+ function main ( { n } ) {
11
+ const b = new Buffer ( 1024 ) ;
12
+ const r = new Readable ( ) ;
13
+ const w = new Writable ( ) ;
14
+
15
+ var i = 0 ;
16
+
17
+ r . _read = ( ) => r . push ( i ++ === n ? null : b ) ;
18
+ w . _write = ( data , enc , cb ) => cb ( ) ;
19
+
20
+ bench . start ( ) ;
21
+
22
+ r . pipe ( w ) ;
23
+ w . on ( 'finish' , ( ) => bench . end ( n ) ) ;
24
+ }
You can’t perform that action at this time.
0 commit comments