MCPcopy Index your code
hub / github.com/idank/explainshell / run_http

Function run_http

tools/loadtest.py:341–384  ·  view source on GitHub ↗
(args: argparse.Namespace)

Source from the content-addressed store, hash-verified

339
340
341async def run_http(args: argparse.Namespace) -> dict:
342 import aiohttp
343
344 rng = random.Random(args.seed)
345 results: list[Result] = []
346 test_start = time.monotonic()
347 stop_at = test_start + args.duration
348
349 connector = aiohttp.TCPConnector(limit=max(args.concurrency * 2, 64))
350 timeout = aiohttp.ClientTimeout(total=None)
351
352 loop_stats = LoopStats()
353 async with aiohttp.ClientSession(connector=connector, timeout=timeout) as session:
354 if args.rps:
355 await _open_loop_scheduler(
356 session,
357 args.url,
358 rng,
359 results,
360 test_start,
361 stop_at,
362 args.rps,
363 args.simple_ratio,
364 args.concurrency,
365 loop_stats,
366 )
367 else:
368 workers = [
369 asyncio.create_task(
370 _closed_loop_worker(
371 session,
372 args.url,
373 rng,
374 results,
375 test_start,
376 stop_at,
377 args.simple_ratio,
378 )
379 )
380 for _ in range(args.concurrency)
381 ]
382 await asyncio.gather(*workers)
383
384 return _build_report(results, loop_stats, args)
385
386
387def _build_report(

Callers 1

mainFunction · 0.85

Calls 5

LoopStatsClass · 0.85
_open_loop_schedulerFunction · 0.85
_closed_loop_workerFunction · 0.85
rangeFunction · 0.85
_build_reportFunction · 0.85

Tested by

no test coverage detected