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/real_swarm_benchmark.py

rUvee6e5bd592bf
diff --git a/benchmark/.claude/checkpoints/1754446746.json b/benchmark/.claude/checkpoints/1754446746.json
new file mode 100644
index 0000000000..fce8be4b16
--- /dev/null
+++ b/benchmark/.claude/checkpoints/1754446746.json
@@ -0,0 +1 @@
+{"branch": "checkpoint/pre-edit-20250806-021906", "file": "/workspaces/claude-code-flow/benchmark/src/swarm_benchmark/core/claude_flow_real_executor.py", "timestamp": "2025-08-06T02:19:06Z", "type": "pre-edit", "original_branch": "alpha-88"}
diff --git a/benchmark/.claude/checkpoints/1754446747.json b/benchmark/.claude/checkpoints/1754446747.json
new file mode 100644
index 0000000000..8555376010
--- /dev/null
+++ b/benchmark/.claude/checkpoints/1754446747.json
@@ -0,0 +1 @@
+{"tag": "checkpoint-20250806-021907", "file": "/workspaces/claude-code-flow/benchmark/src/swarm_benchmark/core/claude_flow_real_executor.py", "timestamp": "2025-08-06T02:19:07Z", "type": "post-edit", "branch": "alpha-88", "diff_summary": " .claude-flow/metrics/system-metrics.json | 96 +++ benchmark/.claude-flow/metrics/performance.json | 2 +- benchmark/.claude-flow/metrics/task-metrics.json | 6 +- benchmark/.claude/checkpoints/1754446680.json | 1 + benchmark/.claude/checkpoints/1754446681.json | 1 + benchmark/ci_performance_integration.py | 754 ----------------- benchmark/compare_optimizations.py | 172 ---- benchmark/continuous_performance_monitor.py | 673 --------------- benchmark/demo_comprehensive.py | 233 ----- benchmark/demo_mle_star.py | 152 ---- benchmark/demo_real_benchmark.py | 219 ----- benchmark/example_usage.py | 249 ------ benchmark/hello_world.py | 21 - benchmark/hive-mind-load-test.py | 902 -------------------- benchmark/hive-mind-stress-test.py | 935 --------------------- benchmark/mle_star_benchmark_example.py | 229 ----- benchmark/performance_dashboard.py | 769 ----------------- benchmark/quick_test_integration.py | 44 - benchmark/run-load-tests.py | 479 ----------- benchmark/run_performance_tests.py | 550 ------------ benchmark/simple-load-test.py | 322 ------- .../core/claude_flow_real_executor.py | 595 +++++++++++++ benchmark/swarm_performance_suite.py | 840 ------------------ benchmark/test_claude_optimizer.py | 235 ------ benchmark/test_hello_world.py | 33 - benchmark/test_integration.py | 274 ------ benchmark/test_mle_star_integration.py | 225 ----- benchmark/test_real_benchmark_engine.py | 317 ------- benchmark/test_real_claude_flow.py | 218 ----- benchmark/test_real_metrics.py | 128 --- benchmark/test_real_simple.py | 104 --- benchmark/test_simple_run.py | 35 - .../tests/integration/quick_test_integration.py | 2 +- .../tests/integration/test_claude_optimizer.py | 2 +- benchmark/tests/integration/test_integration.py | 2 +- .../tests/integration/test_mle_star_integration.py | 4 +- .../integration/test_real_benchmark_engine.py | 4 +- .../tests/integration/test_real_claude_flow.py | 2 +- benchmark/tests/integration/test_real_metrics.py | 2 +- benchmark/tests/integration/test_simple_run.py | 2 +- claude-flow-wiki | 0 41 files changed, 707 insertions(+), 9126 deletions(-) "}
diff --git a/benchmark/examples/real_swarm_benchmark.py b/benchmark/examples/real_swarm_benchmark.py
new file mode 100644
index 0000000000..5dd40a6898
--- /dev/null
+++ b/benchmark/examples/real_swarm_benchmark.py
@@ -0,0 +1,146 @@
+#!/usr/bin/env python3
+"""
+Real Swarm Benchmark Example - Execute and measure real swarm performance.
+
+This example demonstrates how to:
+1. Execute real Claude Flow swarm commands
+2. Measure actual performance metrics
+3. Parse real JSON streaming responses
+4. Track token usage from actual Claude responses
+
+Usage:
+ python real_swarm_benchmark.py [task_description]
+"""
+
+import sys
+import json
+import argparse
+from pathlib import Path
+
+# Add src to path
+sys.path.insert(0, str(Path(__file__).parent.parent / "src"))
+
+from swarm_benchmark.scenarios.real_benchmarks import RealSwarmBenchmark, RealBenchmarkResult
+
+
+def run_swarm_benchmark(task: str, strategy: str = "auto", mode: str = "hierarchical") -> RealBenchmarkResult:
+ """
+ Run a real swarm benchmark.
+
+ Args:
+ task: Task description
+ strategy: Execution strategy
+ mode: Coordination mode
+
+ Returns:
+ RealBenchmarkResult with actual metrics
+ """
+ print(f"πŸš€ Starting Real Swarm Benchmark")
+ print(f" Task: {task}")
+ print(f" Strategy: {strategy}")
+ print(f" Mode: {mode}")
+ print("-" * 60)
+
+ # Initialize benchmark
+ benchmark = RealSwarmBenchmark()
+
+ # Execute real swarm
+ result = benchmark.executor.execute_swarm(
+ objective=task,
+ strategy=strategy,
+ mode=mode,
+ max_agents=5,
+ timeout=10,
+ non_interactive=True
+ )
+
+ # Display results
+ print(f"βœ… Benchmark Complete!")
+ print(f" Success: {result.success}")
+ print(f" Execution Time: {result.execution_time:.2f}s")
+ print(f" Tokens Used: {result.tokens_used}")
+ print(f" Agents Spawned: {result.agents_spawned}")
+ print(f" Memory Usage: {result.memory_usage_mb:.2f} MB")
+ print(f" CPU Usage: {result.cpu_usage_percent:.1f}%")
+ print(f" Output Size: {result.output_size_bytes} bytes")
+ print(f" Errors: {result.error_count}")
+ print(f" Warnings: {result.warning_count}")
+
+ if result.stdout_excerpt:
+ print(f"\nπŸ“‹ Output Excerpt:")
+ print(result.stdout_excerpt)
+
+ if result.stderr_excerpt and result.error_count > 0:
+ print(f"\n❌ Error Excerpt:")
+ print(result.stderr_excerpt)
+
+ return result
+
+
+def run_multiple_benchmarks():
+ """Run multiple swarm benchmarks with different configurations."""
+ print("πŸ”₯ Running Multiple Real Swarm Benchmarks")
+ print("=" * 60)
+
+ benchmark_configs = [
+ ("Create a REST API for user management", "development", "centralized"),
+ ("Analyze system performance bottlenecks", "analysis", "distributed"),
+ ("Research modern web development frameworks", "research", "mesh"),
+ ("Optimize database query performance", "optimization", "hierarchical"),
+ ("Test API endpoint functionality", "testing", "hybrid")
+ ]
+
+ results = []
+
+ for i, (task, strategy, mode) in enumerate(benchmark_configs, 1):
+ print(f"\n🎯 Benchmark {i}/{len(benchmark_configs)}")
+ result = run_swarm_benchmark(task, strategy, mode)
+ results.append(result)
+ print("=" * 60)
+
+ # Save comprehensive results
+ output_file = Path("real_swarm_benchmark_results.json")
+ with open(output_file, 'w') as f:
+ json.dump([r.to_dict() for r in results], f, indent=2)
+
+ print(f"\nπŸ’Ύ Results saved to: {output_file}")
+
+ # Summary statistics
+ total_time = sum(r.execution_time for r in results)
+ total_tokens = sum(r.tokens_used for r in results)
+ total_agents = sum(r.agents_spawned for r in results)
+ success_rate = sum(1 for r in results if r.success) / len(results) * 100
+
+ print(f"\nπŸ“Š Summary Statistics:")
+ print(f" Total Execution Time: {total_time:.2f}s")
+ print(f" Total Tokens Used: {total_tokens}")
+ print(f" Total Agents Spawned: {total_agents}")
+ print(f" Success Rate: {success_rate:.1f}%")
+ print(f" Average Time per Benchmark: {total_time/len(results):.2f}s")
+
+
+def main():
+ """Main entry point."""
+ parser = argparse.ArgumentParser(description="Real Swarm Benchmark Example")
+ parser.add_argument("task", nargs="?",
+ default="Create a simple web application with authentication",
+ help="Task description for the swarm")
+ parser.add_argument("--strategy", default="auto",
+ choices=["auto", "development", "research", "analysis", "testing", "optimization"],
+ help="Execution strategy")
+ parser.add_argument("--mode", default="hierarchical",
+ choices=["centralized", "distributed", "hierarchical", "mesh", "hybrid"],
+ help="Coordination mode")
+ parser.add_argument("--multiple", action="store_true",
+ help="Run multiple benchmark scenarios")
+
+ args = parser.parse_args()
+
+ if args.multiple:
+ run_multiple_benchmarks()
+ else:
+ run_swarm_benchmark(args.task, args.strategy, args.mode)
+
+
+if __name__ == "__main__":
+ main()
\ No newline at end of file