|
|
|
|
|
"""Performance validation script for hackathon demo functionality.""" |
|
|
|
|
|
import time |
|
|
|
|
|
import app |
|
|
|
|
|
|
|
|
def test_response_times(): |
|
|
"""Test response times for key hackathon demo queries.""" |
|
|
|
|
|
print("β‘ KGraph-MCP Performance Validation") |
|
|
print("=" * 50) |
|
|
print() |
|
|
|
|
|
|
|
|
print("π Initializing agent system...") |
|
|
start = time.time() |
|
|
planner, executor = app.initialize_agent_system() |
|
|
|
|
|
|
|
|
app.planner_agent = planner |
|
|
app.executor_agent = executor |
|
|
|
|
|
init_time = (time.time() - start) * 1000 |
|
|
print(f" π€ Agent Initialization: {init_time:.0f}ms {'β
' if init_time < 10000 else 'π‘'}") |
|
|
|
|
|
if planner is None or executor is None: |
|
|
print(" β Agent initialization failed!") |
|
|
print(" π Platform Status: β NOT READY") |
|
|
return |
|
|
print(" β
Agent system ready!") |
|
|
print() |
|
|
|
|
|
queries = [ |
|
|
"analyze customer sentiment from reviews", |
|
|
"summarize technical documentation for team", |
|
|
"check code quality and security issues", |
|
|
"perform sentiment analysis on feedback", |
|
|
"generate structured summaries of research" |
|
|
] |
|
|
|
|
|
total_time = 0 |
|
|
successful_queries = 0 |
|
|
|
|
|
for i, query in enumerate(queries, 1): |
|
|
print(f"π Test {i}/5: {query[:45]}...") |
|
|
|
|
|
start = time.time() |
|
|
try: |
|
|
result = app.handle_generate_plan(query) |
|
|
end = time.time() |
|
|
response_time = (end - start) * 1000 |
|
|
|
|
|
status = result.get("status", "unknown") |
|
|
steps = len(result.get("planned_steps", [])) |
|
|
|
|
|
print(f" β±οΈ Response Time: {response_time:.0f}ms") |
|
|
print(f" π Status: {status}") |
|
|
print(f" π― Planned Steps: {steps}") |
|
|
|
|
|
if status == "success": |
|
|
performance = "β
EXCELLENT" if response_time < 2000 else "π‘ ACCEPTABLE" if response_time < 5000 else "β SLOW" |
|
|
print(f" π Performance: {performance}") |
|
|
total_time += response_time |
|
|
successful_queries += 1 |
|
|
else: |
|
|
print(f" β Error: {result.get('message', 'Unknown error')}") |
|
|
|
|
|
except Exception as e: |
|
|
print(f" π₯ Exception: {e}") |
|
|
|
|
|
print() |
|
|
|
|
|
|
|
|
avg_time = total_time / successful_queries if successful_queries > 0 else float("inf") |
|
|
|
|
|
print("π Performance Summary") |
|
|
print("=" * 30) |
|
|
print(f"β
Successful Queries: {successful_queries}/{len(queries)}") |
|
|
|
|
|
if successful_queries > 0: |
|
|
print(f"β‘ Average Response Time: {avg_time:.0f}ms") |
|
|
print("π― Target: < 2000ms") |
|
|
|
|
|
if avg_time < 2000: |
|
|
print("π HACKATHON READY: Excellent performance!") |
|
|
elif avg_time < 5000: |
|
|
print("π‘ ACCEPTABLE: Good for demo, could optimize") |
|
|
else: |
|
|
print("β NEEDS OPTIMIZATION: Too slow for competition") |
|
|
else: |
|
|
print("β NO SUCCESSFUL QUERIES: System needs investigation") |
|
|
|
|
|
print("\nπ§ͺ Additional Validation:") |
|
|
|
|
|
|
|
|
start = time.time() |
|
|
interface = app.create_gradio_interface() |
|
|
interface_time = (time.time() - start) * 1000 |
|
|
print(f"π± Interface Creation: {interface_time:.0f}ms {'β
' if interface_time < 1000 else 'π‘'}") |
|
|
|
|
|
print(f"\nπ Platform Status: {'β
HACKATHON READY' if avg_time < 2000 and successful_queries >= 4 else 'π‘ NEEDS ATTENTION'}") |
|
|
|
|
|
if __name__ == "__main__": |
|
|
test_response_times() |
|
|
|