Files
ruflo/v2/benchmark/examples/basic/benchmark_with_reports.py
T
rUvandClaude Opus 4.5 1b6a1971f7 feat(v3): add comprehensive v3 implementation plans and swarm architecture
- Reorganize v3/ into implementation/ subfolders:
  - planning/, architecture/, migration/, integration/
  - security/, adrs/, research/, swarm-plans/

- Add 15-agent concurrent swarm implementation plans:
  - SWARM-OVERVIEW.md: Hierarchical mesh topology, 4 phases
  - AGENT-SPECIFICATIONS.md: 15 agent configs with capabilities
  - TDD-LONDON-SCHOOL-PLAN.md: Mock-first TDD methodology
  - BENCHMARK-OPTIMIZATION.md: Performance targets (2.49x-7.47x)
  - DEPLOYMENT-PLAN.md: Release strategy, CI/CD, rollback
  - GITHUB-ISSUE-TRACKING.md: Issue workflow with agent replies

- Update .claude/settings.json with proper hooks format
- Add bash aliases for claude --dangerously-skip-permissions

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-04 15:40:51 +00:00

71 lines
2.3 KiB
Python

#!/usr/bin/env python3
"""
Example showing the improved benchmark reporting with detailed metrics and file references.
"""
import subprocess
import json
from pathlib import Path
import sys
def run_benchmark_with_report(task, strategy="auto"):
"""Run a benchmark and display the improved report."""
print(f"\n🚀 Running benchmark: {task}")
print("-" * 60)
cmd = [
"swarm-benchmark", "real", "swarm",
task,
"--strategy", strategy,
"--timeout", "2",
"--output-dir", "./my-benchmarks"
]
result = subprocess.run(cmd, capture_output=True, text=True)
# Display the output (which now includes detailed report)
print(result.stdout)
# Parse the results file if created
results_dir = Path("./my-benchmarks")
if results_dir.exists():
# Find the most recent benchmark file
json_files = list(results_dir.glob("benchmark_*.json"))
if json_files:
latest_file = max(json_files, key=lambda p: p.stat().st_mtime)
print(f"\n📂 Reading results from: {latest_file}")
with open(latest_file) as f:
data = json.load(f)
print("\n🔍 Key Metrics from JSON:")
if 'metrics' in data:
metrics = data['metrics']
print(f" - Execution Time: {metrics.get('wall_clock_time', 'N/A')}s")
print(f" - Success Rate: {metrics.get('success_rate', 'N/A')}")
print(f" - Peak Memory: {metrics.get('peak_memory_mb', 'N/A')} MB")
print(f"\n📊 Benchmark ID: {data.get('benchmark_id', 'N/A')}")
print(f"📋 Status: {data.get('status', 'N/A')}")
return result.returncode == 0
if __name__ == "__main__":
# Example 1: Simple task
success = run_benchmark_with_report(
"Create a hello world function",
strategy="development"
)
# Example 2: More complex task
if success:
run_benchmark_with_report(
"Design a REST API with authentication",
strategy="analysis"
)
print("\n✅ Benchmark examples completed!")
print("Check ./my-benchmarks/ for detailed results files")
sys.exit(0 if success else 1)