MCPcopy
hub / github.com/benoitc/gunicorn / run_payload_suite

Function run_payload_suite

benchmarks/dirty_benchmark.py:647–720  ·  view source on GitHub ↗

Run payload size benchmark suite.

(
    workers: int = 2,
    threads: int = 1,
    verbose: bool = False,
)

Source from the content-addressed store, hash-verified

645
646
647def run_payload_suite(
648 workers: int = 2,
649 threads: int = 1,
650 verbose: bool = False,
651) -> list[BenchmarkResult]:
652 """Run payload size benchmark suite."""
653 results = []
654
655 bench = IsolatedBenchmark(
656 dirty_workers=workers,
657 dirty_threads=threads,
658 verbose=verbose,
659 )
660
661 print(f"\nStarting payload benchmarks (workers={workers})...")
662
663 try:
664 bench.start()
665 bench.warmup()
666
667 # Payload sizes to test
668 payload_sizes = [
669 (100, "100B", "Tiny payload"),
670 (1024, "1KB", "Small payload"),
671 (10240, "10KB", "Medium payload"),
672 (102400, "100KB", "Large payload"),
673 (1048576, "1MB", "Very large payload"),
674 ]
675
676 for size, size_label, description in payload_sizes:
677 # Adjust concurrency for larger payloads
678 concurrency = max(5, 100 // (size // 1024 + 1))
679 requests = max(100, 1000 // (size // 1024 + 1))
680
681 print(f" Running payload_{size_label}: {description}...")
682
683 start_time = time.perf_counter()
684 latencies, errors = bench.run_benchmark(
685 action="payload_task",
686 args=(size,),
687 total_requests=requests,
688 concurrency=concurrency,
689 )
690 duration = time.perf_counter() - start_time
691
692 result = BenchmarkResult(
693 scenario=f"payload_{size_label}",
694 config={
695 "dirty_workers": workers,
696 "dirty_threads": threads,
697 "payload_bytes": size,
698 "concurrency": concurrency,
699 },
700 total_requests=requests,
701 successful=len(latencies),
702 failed=len(errors),
703 errors=errors[:5] if errors else [],
704 duration_sec=round(duration, 2),

Callers 1

mainFunction · 0.85

Calls 7

startMethod · 0.95
warmupMethod · 0.95
run_benchmarkMethod · 0.95
stopMethod · 0.95
IsolatedBenchmarkClass · 0.85
from_samplesMethod · 0.80
BenchmarkResultClass · 0.70

Tested by

no test coverage detected