(args: argparse.Namespace)
| 584 | |
| 585 | |
| 586 | async def run_slowread(args: argparse.Namespace) -> dict: |
| 587 | import urllib.parse as _up |
| 588 | |
| 589 | u = _up.urlparse(args.url) |
| 590 | host = u.hostname or "127.0.0.1" |
| 591 | port = u.port or (443 if u.scheme == "https" else 80) |
| 592 | path = u.path or "/explain" |
| 593 | if not path.endswith("/explain"): |
| 594 | path = path.rstrip("/") + "/explain" |
| 595 | |
| 596 | rng = random.Random(args.seed) |
| 597 | test_start = time.perf_counter() |
| 598 | deadline = test_start + args.duration |
| 599 | |
| 600 | stats = { |
| 601 | "opened": 0, |
| 602 | "completed": 0, |
| 603 | "errors": 0, |
| 604 | "read_timeouts": 0, |
| 605 | "total_bytes": 0, |
| 606 | "durations_s": [], |
| 607 | "err_hist": {}, |
| 608 | } |
| 609 | witness_results: list[Result] = [] |
| 610 | |
| 611 | tasks = [ |
| 612 | asyncio.create_task( |
| 613 | _slow_reader( |
| 614 | host, |
| 615 | port, |
| 616 | path, |
| 617 | random.Random(args.seed + i), |
| 618 | args.read_bps, |
| 619 | args.chunk, |
| 620 | deadline, |
| 621 | test_start, |
| 622 | stats, |
| 623 | ) |
| 624 | ) |
| 625 | for i in range(args.concurrency) |
| 626 | ] |
| 627 | if args.witness_interval > 0: |
| 628 | tasks.append( |
| 629 | asyncio.create_task( |
| 630 | _witness( |
| 631 | args.url, |
| 632 | rng, |
| 633 | deadline, |
| 634 | args.witness_interval, |
| 635 | witness_results, |
| 636 | test_start, |
| 637 | ) |
| 638 | ) |
| 639 | ) |
| 640 | await asyncio.gather(*tasks, return_exceptions=True) |
| 641 | |
| 642 | elapsed = time.perf_counter() - test_start |
| 643 | durs = stats.pop("durations_s") |
no test coverage detected