@@ -200,8 +200,11 @@ def do_bomb(rnd):
200
200
rnd = '' .join (random .sample (string .ascii_letters , 16 ))
201
201
bombs .append (asyncio .async (do_bomb (rnd )))
202
202
203
+ t1 = loop .time ()
203
204
data = (yield from asyncio .gather (* bombs ))
204
- return data
205
+ t2 = loop .time ()
206
+ rps = count / (t2 - t1 )
207
+ return rps , data
205
208
206
209
207
210
@asyncio .coroutine
@@ -230,7 +233,7 @@ def run(test, count, concurrency, *, loop, verbose):
230
233
if verbose :
231
234
test_name = test .__name__
232
235
print ("Attack" , test_name )
233
- data = yield from attack (count , concurrency , connector , loop , url )
236
+ rps , data = yield from attack (count , concurrency , connector , loop , url )
234
237
if verbose :
235
238
print ("Done" )
236
239
@@ -239,7 +242,7 @@ def run(test, count, concurrency, *, loop, verbose):
239
242
assert resp .status == 200 , resp .status
240
243
resp .release ()
241
244
server .join ()
242
- return data
245
+ return rps , data
243
246
244
247
245
248
def main (argv ):
@@ -256,27 +259,26 @@ def main(argv):
256
259
suite *= tries
257
260
random .shuffle (suite )
258
261
259
- results = collections .defaultdict (list )
262
+ all_times = collections .defaultdict (list )
263
+ all_rps = collections .defaultdict (list )
260
264
for test in suite :
261
265
test_name = test .__name__
262
266
263
- times = loop .run_until_complete (run (test , count , concurrency ,
264
- loop = loop , verbose = verbose ))
265
- results [test_name ].append (times )
267
+ rps , times = loop .run_until_complete (run (test , count , concurrency ,
268
+ loop = loop , verbose = verbose ))
269
+ all_times [test_name ].extend (times )
270
+ all_rps [test_name ].append (rps )
266
271
267
272
print ()
268
273
269
- for test_name in sorted (results ):
274
+ for test_name in sorted (all_rps ):
275
+ rps = array (all_rps [test_name ])
276
+ times = array (all_times [test_name ]) * 1000
270
277
271
- data = array (results [test_name ])
272
- trimmed = masked_equal (data , 0 )
273
-
274
- rps = trimmed .size / trimmed
275
278
rps_mean = tmean (rps )
276
- times = trimmed * 1000000 / trimmed .size
277
279
times_mean = tmean (times )
278
280
times_stdev = tstd (times )
279
- times_median = median (times )
281
+ times_median = float ( median (times ) )
280
282
print ('Results for' , test_name )
281
283
print ('RPS: {:d},\t mean: {:.3f} μs,'
282
284
'\t standard deviation {:.3f} μs\t median {:.3f} μs'
0 commit comments