Skip to content

armgit / ruflo

Public Imported from GitHub
0

🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated

πŸ”– Checkpoint: Edit /workspaces/claude-code-flow/benchmark/examples/reporting/compare_benchmarks.py

rUv12c5dabacfe9
diff --git a/.claude/checkpoints/1754481481.json b/.claude/checkpoints/1754481481.json
new file mode 100644
index 0000000000..f008960fe9
--- /dev/null
+++ b/.claude/checkpoints/1754481481.json
@@ -0,0 +1 @@
+{"branch": "checkpoint/pre-edit-20250806-115801", "file": "/workspaces/claude-code-flow/benchmark/examples/reporting/realtime_monitor.py", "timestamp": "2025-08-06T11:58:01Z", "type": "pre-edit", "original_branch": "alpha-88"}
diff --git a/.claude/checkpoints/1754481483.json b/.claude/checkpoints/1754481483.json
new file mode 100644
index 0000000000..a05e160ec1
--- /dev/null
+++ b/.claude/checkpoints/1754481483.json
@@ -0,0 +1 @@
+{"tag": "checkpoint-20250806-115803", "file": "/workspaces/claude-code-flow/benchmark/examples/reporting/realtime_monitor.py", "timestamp": "2025-08-06T11:58:03Z", "type": "post-edit", "branch": "alpha-88", "diff_summary": " .claude-flow/metrics/performance.json | 2 +- .claude-flow/metrics/system-metrics.json | 156 +++++++++++ .claude-flow/metrics/task-metrics.json | 6 +- .claude/checkpoints/1754481418.json | 1 + .claude/checkpoints/1754481420.json | 1 + benchmark/examples/reporting/realtime_monitor.py | 305 +++++++++++++++++++++ .../cli/__pycache__/main.cpython-312.pyc | Bin 29784 -> 36741 bytes benchmark/test_improved_report.py | 35 --- claude-flow-wiki | 0 9 files changed, 467 insertions(+), 39 deletions(-) "}
diff --git a/benchmark/examples/reporting/compare_benchmarks.py b/benchmark/examples/reporting/compare_benchmarks.py
new file mode 100644
index 0000000000..3d9a0fe4b0
--- /dev/null
+++ b/benchmark/examples/reporting/compare_benchmarks.py
@@ -0,0 +1,220 @@
+#!/usr/bin/env python3
+"""
+Compare Multiple Benchmark Reports
+Analyze and compare performance across different benchmark runs.
+"""
+
+import json
+from pathlib import Path
+from typing import List, Dict, Tuple
+import subprocess
+from datetime import datetime
+
+class BenchmarkComparator:
+ """Compare multiple benchmark reports."""
+
+ def __init__(self, report_dir: Path = Path("reports")):
+ self.report_dir = report_dir
+
+ def run_comparison_benchmark(self, tasks: List[Tuple[str, str]]) -> None:
+ """Run multiple benchmarks for comparison."""
+
+ print("="*80)
+ print("πŸ”¬ BENCHMARK COMPARISON SUITE")
+ print("="*80)
+ print(f"Running {len(tasks)} benchmark configurations...")
+ print("-"*80)
+
+ results = []
+
+ for i, (task, strategy) in enumerate(tasks, 1):
+ print(f"\nπŸ“Š Benchmark {i}/{len(tasks)}")
+ print(f" Task: {task}")
+ print(f" Strategy: {strategy}")
+
+ # Run benchmark
+ cmd = [
+ "swarm-benchmark", "real", "swarm",
+ task,
+ "--strategy", strategy,
+ "--timeout", "5",
+ "--output-dir", str(self.report_dir)
+ ]
+
+ start_time = datetime.now()
+ result = subprocess.run(cmd, capture_output=True, text=True)
+ end_time = datetime.now()
+
+ # Parse output to find benchmark ID
+ benchmark_id = None
+ for line in result.stdout.split('\n'):
+ if "Benchmark ID:" in line:
+ benchmark_id = line.split(":")[-1].strip()
+ break
+
+ results.append({
+ 'task': task,
+ 'strategy': strategy,
+ 'benchmark_id': benchmark_id,
+ 'duration': (end_time - start_time).total_seconds(),
+ 'success': result.returncode == 0
+ })
+
+ if result.returncode == 0:
+ print(f" βœ… Success in {results[-1]['duration']:.2f}s")
+ else:
+ print(f" ❌ Failed after {results[-1]['duration']:.2f}s")
+
+ # Generate comparison report
+ self._generate_comparison_report(results)
+
+ def _generate_comparison_report(self, results: List[Dict]) -> None:
+ """Generate detailed comparison report."""
+
+ print("\n" + "="*80)
+ print("πŸ“Š COMPARISON REPORT")
+ print("="*80)
+
+ # Load detailed metrics for each benchmark
+ detailed_results = []
+ for result in results:
+ if result['benchmark_id'] and result['success']:
+ report_file = self.report_dir / f"benchmark_{result['benchmark_id']}.json"
+ if report_file.exists():
+ with open(report_file) as f:
+ data = json.load(f)
+ result['details'] = data
+ detailed_results.append(result)
+
+ if not detailed_results:
+ print("No successful benchmarks to compare")
+ return
+
+ # Performance comparison
+ print("\n⚑ PERFORMANCE COMPARISON:")
+ print("-"*80)
+ print(f"{'Task':<30} {'Strategy':<15} {'Time (s)':<12} {'Success Rate':<15} {'Memory (MB)':<12}")
+ print("-"*80)
+
+ for result in detailed_results:
+ details = result['details']
+ metrics = details.get('metrics', {})
+
+ task_short = result['task'][:28] + ".." if len(result['task']) > 30 else result['task']
+
+ print(f"{task_short:<30} {result['strategy']:<15} "
+ f"{details.get('duration', 0):<12.2f} "
+ f"{metrics.get('success_rate', 0):<15.1%} "
+ f"{metrics.get('peak_memory_mb', 0):<12.1f}")
+
+ # Find best performers
+ if len(detailed_results) > 1:
+ print("\nπŸ† BEST PERFORMERS:")
+ print("-"*80)
+
+ # Fastest
+ fastest = min(detailed_results, key=lambda r: r['details'].get('duration', float('inf')))
+ print(f"⚑ Fastest: {fastest['task'][:40]} ({fastest['strategy']}) - {fastest['details'].get('duration', 0):.2f}s")
+
+ # Most reliable
+ most_reliable = max(detailed_results,
+ key=lambda r: r['details'].get('metrics', {}).get('success_rate', 0))
+ reliability = most_reliable['details'].get('metrics', {}).get('success_rate', 0)
+ print(f"βœ… Most Reliable: {most_reliable['task'][:40]} ({most_reliable['strategy']}) - {reliability:.1%}")
+
+ # Most efficient (lowest memory)
+ most_efficient = min(detailed_results,
+ key=lambda r: r['details'].get('metrics', {}).get('peak_memory_mb', float('inf')))
+ memory = most_efficient['details'].get('metrics', {}).get('peak_memory_mb', 0)
+ print(f"πŸ’Ύ Most Efficient: {most_efficient['task'][:40]} ({most_efficient['strategy']}) - {memory:.1f} MB")
+
+ # Strategy analysis
+ print("\n🎯 STRATEGY ANALYSIS:")
+ print("-"*80)
+
+ strategy_stats = {}
+ for result in detailed_results:
+ strategy = result['strategy']
+ if strategy not in strategy_stats:
+ strategy_stats[strategy] = {
+ 'count': 0,
+ 'total_time': 0,
+ 'success_rates': [],
+ 'memory_usage': []
+ }
+
+ stats = strategy_stats[strategy]
+ stats['count'] += 1
+ stats['total_time'] += result['details'].get('duration', 0)
+ stats['success_rates'].append(
+ result['details'].get('metrics', {}).get('success_rate', 0)
+ )
+ stats['memory_usage'].append(
+ result['details'].get('metrics', {}).get('peak_memory_mb', 0)
+ )
+
+ for strategy, stats in strategy_stats.items():
+ avg_time = stats['total_time'] / stats['count']
+ avg_success = sum(stats['success_rates']) / len(stats['success_rates'])
+ avg_memory = sum(stats['memory_usage']) / len(stats['memory_usage']) if stats['memory_usage'] else 0
+
+ print(f"\nπŸ“Œ Strategy: {strategy}")
+ print(f" β€’ Benchmarks Run: {stats['count']}")
+ print(f" β€’ Avg Time: {avg_time:.2f}s")
+ print(f" β€’ Avg Success Rate: {avg_success:.1%}")
+ print(f" β€’ Avg Memory: {avg_memory:.1f} MB")
+
+ # Save comparison report
+ comparison_file = self.report_dir / f"comparison_{datetime.now().strftime('%Y%m%d_%H%M%S')}.json"
+ with open(comparison_file, 'w') as f:
+ json.dump({
+ 'timestamp': datetime.now().isoformat(),
+ 'benchmarks': detailed_results,
+ 'strategy_analysis': strategy_stats
+ }, f, indent=2, default=str)
+
+ print(f"\nπŸ“„ Comparison report saved to: {comparison_file}")
+ print("="*80)
+
+def main():
+ """Main entry point for benchmark comparison."""
+ import argparse
+
+ parser = argparse.ArgumentParser(description="Compare multiple Claude Flow benchmarks")
+ parser.add_argument("--preset", choices=["quick", "thorough", "strategies"],
+ default="quick", help="Preset comparison suite")
+ parser.add_argument("--output-dir", default="reports", help="Output directory")
+
+ args = parser.parse_args()
+
+ # Define preset benchmark suites
+ presets = {
+ "quick": [
+ ("Create a simple function", "development"),
+ ("Write unit tests", "testing"),
+ ("Analyze code quality", "analysis")
+ ],
+ "thorough": [
+ ("Build REST API with authentication", "development"),
+ ("Build REST API with authentication", "planning"),
+ ("Build REST API with authentication", "analysis"),
+ ("Implement data processing pipeline", "development"),
+ ("Implement data processing pipeline", "optimization")
+ ],
+ "strategies": [
+ ("Design a microservice", "auto"),
+ ("Design a microservice", "development"),
+ ("Design a microservice", "planning"),
+ ("Design a microservice", "analysis"),
+ ("Design a microservice", "testing"),
+ ("Design a microservice", "optimization")
+ ]
+ }
+
+ tasks = presets[args.preset]
+
+ comparator = BenchmarkComparator(Path(args.output_dir))
+ comparator.run_comparison_benchmark(tasks)
+
+if __name__ == "__main__":
+ main()
\ No newline at end of file