File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change 22
33const common = require ( '../common.js' ) ;
44const dgram = require ( 'dgram' ) ;
5+ const assert = require ( 'assert' ) ;
56
67const bench = common . createBenchmark ( main , {
78 n : [ 5e6 ] ,
89 method : [ 'size' , 'count' ] ,
10+ } , {
11+ flags : [ '--test-udp-no-try-send' ] ,
912} ) ;
1013
1114function main ( { n, method } ) {
@@ -14,20 +17,27 @@ function main({ n, method }) {
1417
1518 server . bind ( 0 , ( ) => {
1619 client . connect ( server . address ( ) . port , ( ) => {
20+ // warm-up: keep packets unsent using --test-udp-no-try-send flag
1721 for ( let i = 0 ; i < 999 ; i ++ ) client . send ( 'Hello' ) ;
1822
23+ let size = 0 ;
24+ let count = 0 ;
25+
1926 bench . start ( ) ;
2027
2128 if ( method === 'size' ) {
22- for ( let i = 0 ; i < n ; ++ i ) server . getSendQueueSize ( ) ;
29+ for ( let i = 0 ; i < n ; ++ i ) size += client . getSendQueueSize ( ) ;
2330 } else {
24- for ( let i = 0 ; i < n ; ++ i ) server . getSendQueueCount ( ) ;
31+ for ( let i = 0 ; i < n ; ++ i ) count += client . getSendQueueCount ( ) ;
2532 }
2633
2734 bench . end ( n ) ;
2835
2936 client . close ( ) ;
3037 server . close ( ) ;
38+
39+ assert . ok ( size > 0 ) ;
40+ assert . ok ( count > 0 ) ;
3141 } ) ;
3242 } ) ;
3343}
You can’t perform that action at this time.
0 commit comments