(args: argparse.Namespace)
| 339 | |
| 340 | |
| 341 | async 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 | |
| 387 | def _build_report( |
no test coverage detected