DeepBoner / examples /benchmark_advanced.py
VibecoderMcSwaggins's picture
feat: SPEC_15 Advanced Mode Performance Optimization (#101)
3cb2e43 unverified
raw
history blame
1.3 kB
"""Benchmark Advanced mode with different max_rounds settings."""
import asyncio
import time
from src.orchestrators.advanced import AdvancedOrchestrator
async def benchmark(max_rounds: int) -> float:
"""Run benchmark with specified rounds, return elapsed time."""
# Pass max_rounds explicitly instead of mutating os.environ
orch = AdvancedOrchestrator(max_rounds=max_rounds)
start = time.time()
print(f"\nStarting benchmark with max_rounds={max_rounds}...")
try:
async for event in orch.run("sildenafil erectile dysfunction mechanism"):
if event.type == "progress":
print(f" Progress: {event.message}")
elif event.type == "complete":
print(" Complete!")
break
elif event.type == "error":
print(f" Error: {event.message}")
break
except Exception as e:
print(f" Exception: {e}")
return time.time() - start
async def main() -> None:
"""Run benchmarks for different configurations."""
# Only run a quick test for 3 rounds to verify it works
rounds = 3
elapsed = await benchmark(rounds)
print(f"max_rounds={rounds}: {elapsed:.1f}s ({elapsed / 60:.1f}min)")
if __name__ == "__main__":
asyncio.run(main())