Run async benchmark iterations.
(args: argparse.Namespace, config: LoadGeneratorConfig, description: str)
| 1242 | |
| 1243 | |
| 1244 | async def _run_async_benchmark(args: argparse.Namespace, config: LoadGeneratorConfig, description: str) -> int: |
| 1245 | """Run async benchmark iterations.""" |
| 1246 | results: List[BenchmarkResult] = [] |
| 1247 | for i in range(args.iterations): |
| 1248 | print(f"\n--- Iteration {i + 1}/{args.iterations} ---") |
| 1249 | |
| 1250 | if args.scenario == "baseline": |
| 1251 | result = await run_baseline_scenario_async(tag=args.baseline_tag, config=config) |
| 1252 | if result is None: |
| 1253 | print("ERROR: Baseline benchmark failed") |
| 1254 | return 1 |
| 1255 | else: |
| 1256 | result = await run_iteration_async(args.scenario, config, description) |
| 1257 | |
| 1258 | results.append(result) |
| 1259 | print(f" Ops/sec: {result.operations_per_second:,.0f}") |
| 1260 | |
| 1261 | # Average results across all iterations |
| 1262 | final_result = average_results(results) |
| 1263 | |
| 1264 | # Output results |
| 1265 | if args.json: |
| 1266 | print(json.dumps(asdict(final_result), indent=2)) |
| 1267 | else: |
| 1268 | print_result(final_result, iterations=args.iterations) |
| 1269 | |
| 1270 | return 0 |
| 1271 | |
| 1272 | |
| 1273 | if __name__ == "__main__": |
no test coverage detected