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

rUvcd14fdf5b776
diff --git a/benchmark/.claude/checkpoints/1754446838.json b/benchmark/.claude/checkpoints/1754446838.json
new file mode 100644
index 0000000000..47dcb7cced
--- /dev/null
+++ b/benchmark/.claude/checkpoints/1754446838.json
@@ -0,0 +1 @@
+{"branch": "checkpoint/pre-edit-20250806-022038", "file": "/workspaces/claude-code-flow/benchmark/src/swarm_benchmark/core/benchmark_engine.py", "timestamp": "2025-08-06T02:20:38Z", "type": "pre-edit", "original_branch": "alpha-88"}
diff --git a/benchmark/.claude/checkpoints/1754446840.json b/benchmark/.claude/checkpoints/1754446840.json
new file mode 100644
index 0000000000..77828bfa08
--- /dev/null
+++ b/benchmark/.claude/checkpoints/1754446840.json
@@ -0,0 +1 @@
+{"tag": "checkpoint-20250806-022040", "file": "/workspaces/claude-code-flow/benchmark/src/swarm_benchmark/core/benchmark_engine.py", "timestamp": "2025-08-06T02:20:40Z", "type": "post-edit", "branch": "alpha-88", "diff_summary": " .claude-flow/metrics/system-metrics.json | 132 +++ benchmark/.claude-flow/metrics/performance.json | 2 +- benchmark/.claude-flow/metrics/task-metrics.json | 6 +- benchmark/.claude/checkpoints/1754446825.json | 1 + benchmark/.claude/checkpoints/1754446827.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 ------- .../src/swarm_benchmark/core/benchmark_engine.py | 15 +- 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, 162 insertions(+), 9127 deletions(-) "}
diff --git a/benchmark/test_real_benchmarks.py b/benchmark/test_real_benchmarks.py
new file mode 100644
index 0000000000..ad2a80d3df
--- /dev/null
+++ b/benchmark/test_real_benchmarks.py
@@ -0,0 +1,334 @@
+#!/usr/bin/env python3
+"""
+Test Real Benchmarks - Validate real benchmark implementations.
+
+This script tests that the real benchmark scenarios can:
+1. Execute actual Claude Flow commands
+2. Parse real responses and extract metrics
+3. Handle errors gracefully
+4. Produce valid benchmark results
+
+Usage:
+ python test_real_benchmarks.py [--quick] [--validate-only]
+"""
+
+import sys
+import json
+import argparse
+import tempfile
+from pathlib import Path
+
+# Add src to path
+sys.path.insert(0, str(Path(__file__).parent / "src"))
+
+from swarm_benchmark.scenarios.real_benchmarks import (
+ RealSwarmBenchmark,
+ RealHiveMindBenchmark,
+ RealSparcBenchmark,
+ RealBenchmarkSuite,
+ ClaudeFlowRealExecutor
+)
+
+
+def test_claude_flow_availability():
+ """Test if claude-flow command is available."""
+ print("πŸ” Testing Claude Flow Availability")
+ print("-" * 40)
+
+ try:
+ executor = ClaudeFlowRealExecutor()
+
+ # Test installation validation
+ is_valid = executor.executor.validate_installation()
+
+ print(f" Claude Flow Path: {executor.executor.claude_flow_path}")
+ print(f" Installation Valid: {is_valid}")
+ print(f" Working Directory: {executor.executor.working_dir}")
+
+ if is_valid:
+ print("βœ… Claude Flow is available and working!")
+ return True
+ else:
+ print("❌ Claude Flow installation issues detected")
+ return False
+
+ except Exception as e:
+ print(f"❌ Claude Flow not available: {e}")
+ return False
+
+
+def test_swarm_benchmark():
+ """Test real swarm benchmark."""
+ print("\nπŸ”¬ Testing Real Swarm Benchmark")
+ print("-" * 40)
+
+ try:
+ benchmark = RealSwarmBenchmark()
+
+ # Run a quick test
+ result = benchmark.benchmark_swarm_task("Create a simple hello world function")
+
+ print(f" Success: {result.success}")
+ print(f" Execution Time: {result.execution_time:.2f}s")
+ print(f" Benchmark Name: {result.benchmark_name}")
+ print(f" Timestamp: {result.timestamp}")
+
+ # Validate result structure
+ result_dict = result.to_dict()
+ required_fields = [
+ 'benchmark_name', 'success', 'execution_time', 'tokens_used',
+ 'agents_spawned', 'memory_usage_mb', 'cpu_usage_percent',
+ 'output_size_bytes', 'command_executed', 'timestamp'
+ ]
+
+ missing_fields = [field for field in required_fields if field not in result_dict]
+ if missing_fields:
+ print(f"❌ Missing fields in result: {missing_fields}")
+ return False
+
+ print("βœ… Swarm benchmark test passed!")
+ return True
+
+ except Exception as e:
+ print(f"❌ Swarm benchmark test failed: {e}")
+ return False
+
+
+def test_hive_mind_benchmark():
+ """Test real hive-mind benchmark."""
+ print("\n🧠 Testing Real Hive-Mind Benchmark")
+ print("-" * 40)
+
+ try:
+ benchmark = RealHiveMindBenchmark()
+
+ # Run a quick test
+ result = benchmark.benchmark_hive_mind("Solve a simple math problem: 2+2")
+
+ print(f" Success: {result.success}")
+ print(f" Execution Time: {result.execution_time:.2f}s")
+ print(f" Benchmark Name: {result.benchmark_name}")
+ print(f" Timestamp: {result.timestamp}")
+
+ # Validate result structure
+ result_dict = result.to_dict()
+ if not all(hasattr(result, field) for field in ['success', 'execution_time', 'benchmark_name']):
+ print("❌ Invalid result structure")
+ return False
+
+ print("βœ… Hive-mind benchmark test passed!")
+ return True
+
+ except Exception as e:
+ print(f"❌ Hive-mind benchmark test failed: {e}")
+ return False
+
+
+def test_sparc_benchmark():
+ """Test real SPARC benchmark."""
+ print("\n⚑ Testing Real SPARC Benchmark")
+ print("-" * 40)
+
+ try:
+ benchmark = RealSparcBenchmark()
+
+ # Run a quick test
+ result = benchmark.benchmark_coder_mode("Write a simple function to add two numbers")
+
+ print(f" Success: {result.success}")
+ print(f" Execution Time: {result.execution_time:.2f}s")
+ print(f" Benchmark Name: {result.benchmark_name}")
+ print(f" Timestamp: {result.timestamp}")
+
+ # Validate result structure
+ result_dict = result.to_dict()
+ if not all(hasattr(result, field) for field in ['success', 'execution_time', 'benchmark_name']):
+ print("❌ Invalid result structure")
+ return False
+
+ print("βœ… SPARC benchmark test passed!")
+ return True
+
+ except Exception as e:
+ print(f"❌ SPARC benchmark test failed: {e}")
+ return False
+
+
+def test_metrics_extraction():
+ """Test metrics extraction from sample output."""
+ print("\nπŸ“Š Testing Metrics Extraction")
+ print("-" * 40)
+
+ try:
+ executor = ClaudeFlowRealExecutor()
+
+ # Test token extraction
+ sample_output1 = "Processing complete. Total tokens: 1250 used in execution."
+ tokens = executor._extract_token_usage(sample_output1)
+ print(f" Token extraction test 1: {tokens} (expected: 1250)")
+
+ sample_output2 = "Agent spawned successfully. 5 agents now active in swarm."
+ agents = executor._extract_agent_count(sample_output2)
+ print(f" Agent extraction test 1: {agents} (expected: 5)")
+
+ # Test error counting
+ sample_error = "ERROR: Connection failed. WARNING: Retrying. ERROR: Still failing."
+ error_count = executor._count_errors(sample_error)
+ warning_count = executor._count_warnings(sample_error)
+ print(f" Error count test: {error_count} (expected: 2)")
+ print(f" Warning count test: {warning_count} (expected: 1)")
+
+ # Test JSON parsing
+ sample_json_output = 'Some text {"metrics": {"performance": 0.95}} more text'
+ metrics = executor._parse_json_metrics(sample_json_output)
+ print(f" JSON parsing test: {metrics}")
+
+ print("βœ… Metrics extraction tests passed!")
+ return True
+
+ except Exception as e:
+ print(f"❌ Metrics extraction test failed: {e}")
+ return False
+
+
+def test_benchmark_suite():
+ """Test comprehensive benchmark suite."""
+ print("\nπŸ”₯ Testing Benchmark Suite")
+ print("-" * 40)
+
+ try:
+ # Create temporary output directory
+ with tempfile.TemporaryDirectory() as temp_dir:
+ suite = RealBenchmarkSuite(output_dir=temp_dir)
+
+ print(f" Output Directory: {temp_dir}")
+ print(f" Suite Initialized: βœ…")
+
+ # Test suite structure
+ assert hasattr(suite, 'swarm_bench'), "Missing swarm_bench"
+ assert hasattr(suite, 'hive_bench'), "Missing hive_bench"
+ assert hasattr(suite, 'sparc_bench'), "Missing sparc_bench"
+
+ print("βœ… Benchmark suite test passed!")
+ return True
+
+ except Exception as e:
+ print(f"❌ Benchmark suite test failed: {e}")
+ return False
+
+
+def run_quick_validation():
+ """Run quick validation without full execution."""
+ print("πŸš€ Running Quick Validation")
+ print("=" * 50)
+
+ tests = [
+ ("Claude Flow Availability", test_claude_flow_availability),
+ ("Metrics Extraction", test_metrics_extraction),
+ ("Benchmark Suite", test_benchmark_suite)
+ ]
+
+ results = []
+ for test_name, test_func in tests:
+ try:
+ result = test_func()
+ results.append((test_name, result))
+ except Exception as e:
+ print(f"❌ {test_name} failed with exception: {e}")
+ results.append((test_name, False))
+
+ # Summary
+ passed = sum(1 for _, result in results if result)
+ total = len(results)
+
+ print(f"\nπŸ“Š Quick Validation Summary:")
+ print(f" Tests Passed: {passed}/{total}")
+ print(f" Success Rate: {passed/total*100:.1f}%")
+
+ for test_name, result in results:
+ status = "βœ…" if result else "❌"
+ print(f" {status} {test_name}")
+
+ return passed == total
+
+
+def run_full_tests():
+ """Run full benchmark tests."""
+ print("πŸš€ Running Full Benchmark Tests")
+ print("=" * 50)
+
+ tests = [
+ ("Claude Flow Availability", test_claude_flow_availability),
+ ("Swarm Benchmark", test_swarm_benchmark),
+ ("Hive-Mind Benchmark", test_hive_mind_benchmark),
+ ("SPARC Benchmark", test_sparc_benchmark),
+ ("Metrics Extraction", test_metrics_extraction),
+ ("Benchmark Suite", test_benchmark_suite)
+ ]
+
+ results = []
+ for test_name, test_func in tests:
+ try:
+ result = test_func()
+ results.append((test_name, result))
+ except Exception as e:
+ print(f"❌ {test_name} failed with exception: {e}")
+ results.append((test_name, False))
+
+ # Summary
+ passed = sum(1 for _, result in results if result)
+ total = len(results)
+
+ print(f"\nπŸ“Š Full Test Summary:")
+ print(f" Tests Passed: {passed}/{total}")
+ print(f" Success Rate: {passed/total*100:.1f}%")
+
+ for test_name, result in results:
+ status = "βœ…" if result else "❌"
+ print(f" {status} {test_name}")
+
+ # Save test results
+ test_results = {
+ "summary": {
+ "total_tests": total,
+ "passed_tests": passed,
+ "success_rate": passed/total*100
+ },
+ "individual_results": [
+ {"test": name, "passed": result} for name, result in results
+ ]
+ }
+
+ with open("benchmark_test_results.json", 'w') as f:
+ json.dump(test_results, f, indent=2)
+
+ print(f"\nπŸ’Ύ Test results saved to: benchmark_test_results.json")
+
+ return passed == total
+
+
+def main():
+ """Main entry point."""
+ parser = argparse.ArgumentParser(description="Test Real Benchmarks")
+ parser.add_argument("--quick", action="store_true",
+ help="Run quick validation only")
+ parser.add_argument("--validate-only", action="store_true",
+ help="Validate structure without executing benchmarks")
+
+ args = parser.parse_args()
+
+ if args.validate_only or args.quick:
+ success = run_quick_validation()
+ else:
+ success = run_full_tests()
+
+ if success:
+ print("\nπŸŽ‰ All tests passed! Real benchmarks are ready for use.")
+ sys.exit(0)
+ else:
+ print("\nπŸ’₯ Some tests failed. Please check the implementation.")
+ sys.exit(1)
+
+
+if __name__ == "__main__":
+ main()
\ No newline at end of file