MCPcopy
hub / github.com/aio-libs/aiohttp / run

Function run

benchmark/async.py:217–251  ·  view source on GitHub ↗
(test, count, concurrency, *, loop, verbose, profile)

Source from the content-addressed store, hash-verified

215
216@asyncio.coroutine
217def run(test, count, concurrency, *, loop, verbose, profile):
218 if verbose:
219 print("Prepare")
220 else:
221 print('.', end='', flush=True)
222 host, port = find_port()
223 barrier = Barrier(2)
224 server = Process(target=test, args=(host, port, barrier, profile))
225 server.start()
226 barrier.wait()
227
228 url = 'http://{}:{}'.format(host, port)
229
230 connector = aiohttp.TCPConnector(loop=loop)
231 with aiohttp.ClientSession(connector=connector) as client:
232
233 for i in range(10):
234 # make server hot
235 resp = yield from client.get(url+'/prepare')
236 assert resp.status == 200, resp.status
237 yield from resp.release()
238
239 if verbose:
240 test_name = test.__name__
241 print("Attack", test_name)
242 rps, data = yield from attack(count, concurrency, client, loop, url)
243 if verbose:
244 print("Done")
245
246 resp = yield from client.get(url+'/stop')
247 assert resp.status == 200, resp.status
248 yield from resp.release()
249
250 server.join()
251 return rps, data
252
253
254def main(argv):

Callers 1

mainFunction · 0.70

Calls 6

find_portFunction · 0.85
attackFunction · 0.85
waitMethod · 0.80
startMethod · 0.45
getMethod · 0.45
releaseMethod · 0.45

Tested by

no test coverage detected