@@ -85,7 +85,10 @@ async function main() {
8585 } ) ;
8686
8787 const end = Date . now ( ) + durationSec * 1000 ;
88- let getOk = 0 , getFail = 0 , postOk = 0 , postFail = 0 ;
88+ let getOk = 0 ,
89+ getFail = 0 ,
90+ postOk = 0 ,
91+ postFail = 0 ;
8992
9093 async function get ( ) {
9194 try {
@@ -98,7 +101,10 @@ async function main() {
98101 }
99102 async function post ( ) {
100103 try {
101- const r = ( await fetch ( `https://localhost:${ server . port } /x` , { method : 'POST' , body : 'b' } as any ) ) as any ;
104+ const r = ( await fetch ( `https://localhost:${ server . port } /x` , {
105+ method : 'POST' ,
106+ body : 'b' ,
107+ } as any ) ) as any ;
102108 await r . text ( ) ;
103109 postOk ++ ;
104110 } catch {
@@ -107,10 +113,7 @@ async function main() {
107113 }
108114
109115 while ( Date . now ( ) < end ) {
110- await Promise . all ( [
111- ...Array . from ( { length : 10 } , get ) ,
112- ...Array . from ( { length : 5 } , post ) ,
113- ] ) ;
116+ await Promise . all ( [ ...Array . from ( { length : 10 } , get ) , ...Array . from ( { length : 5 } , post ) ] ) ;
114117 }
115118
116119 await fetch . close ( ) ;
@@ -119,11 +122,20 @@ async function main() {
119122 const getRate = getOk / ( getOk + getFail ) ;
120123 const postClean = postFail === 0 || postOk > 0 ;
121124
122- console . log ( JSON . stringify ( {
123- getOk, getFail, getSuccessRate : Number ( getRate . toFixed ( 3 ) ) ,
124- postOk, postFail,
125- durationSec,
126- } , null , 2 ) ) ;
125+ console . log (
126+ JSON . stringify (
127+ {
128+ getOk,
129+ getFail,
130+ getSuccessRate : Number ( getRate . toFixed ( 3 ) ) ,
131+ postOk,
132+ postFail,
133+ durationSec,
134+ } ,
135+ null ,
136+ 2 ,
137+ ) ,
138+ ) ;
127139
128140 if ( getRate < 0.5 ) {
129141 console . error ( 'GET success rate too low' ) ;
0 commit comments