golem-flask-backend / TEST_SPEED_NOW.py
mememechez's picture
Deploy final cleaned source code
ca28016
#!/usr/bin/env python3
"""
πŸš€ COMPREHENSIVE SPEED TEST FOR QWEN2GOLEM
Tests all components to verify speed targets are met
"""
import time
import requests
import json
import base64
import sys
def test_text_response():
"""Test simple text response speed (Target: <6s)"""
print("\nπŸ“ Testing Text Response (Target: <6s)...")
start = time.time()
try:
response = requests.post(
'http://127.0.0.1:5000/generate',
json={
'prompt': 'Hello! How are you today?',
'sessionId': f'speed-test-{int(time.time())}',
'temperature': 0.3,
'golemActivated': False,
'consciousnessDimension': 'mental',
'selectedModel': 'gemini',
'performSearch': False
},
timeout=10
)
elapsed = time.time() - start
if response.status_code == 200:
data = response.json()
text = data.get('directResponse', data.get('response', ''))[:100]
status = "βœ… PASS" if elapsed < 6 else "❌ FAIL"
print(f" Response: {text}...")
print(f" Time: {elapsed:.2f}s {status}")
return elapsed < 6
else:
print(f" ❌ Error {response.status_code}")
return False
except Exception as e:
print(f" ❌ Error: {str(e)}")
return False
def test_web_search():
"""Test text with web search (Target: <8s)"""
print("\nπŸ” Testing Text + Web Search (Target: <8s)...")
start = time.time()
try:
response = requests.post(
'http://127.0.0.1:5000/generate',
json={
'prompt': 'What is the weather like today?',
'sessionId': f'search-test-{int(time.time())}',
'temperature': 0.3,
'golemActivated': False,
'consciousnessDimension': 'mental',
'selectedModel': 'gemini',
'performSearch': True
},
timeout=12
)
elapsed = time.time() - start
if response.status_code == 200:
status = "βœ… PASS" if elapsed < 8 else "❌ FAIL"
print(f" Time: {elapsed:.2f}s {status}")
return elapsed < 8
else:
print(f" ❌ Error {response.status_code}")
return False
except Exception as e:
print(f" ❌ Error: {str(e)}")
return False
def test_asr():
"""Test ASR transcription (Target: <2s)"""
print("\n🎀 Testing ASR Transcription (Target: <2s)...")
# Create dummy audio (1 second of silence)
dummy_audio = base64.b64encode(b'\x00' * 16000).decode()
start = time.time()
try:
response = requests.post(
'http://127.0.0.1:5000/asr/transcribe',
json={'audio_base64': dummy_audio, 'vad': True},
timeout=5
)
elapsed = time.time() - start
if response.status_code == 200:
status = "βœ… PASS" if elapsed < 2 else "⚠️ SLOW"
print(f" Time: {elapsed:.2f}s {status}")
return elapsed < 2
else:
print(f" ❌ Error {response.status_code}")
return False
except Exception as e:
print(f" ❌ Error: {str(e)}")
return False
def test_tts():
"""Test TTS synthesis (Target: <1s)"""
print("\nπŸ”Š Testing TTS Synthesis (Target: <1s)...")
start = time.time()
try:
response = requests.post(
'http://127.0.0.1:5000/tts/synthesize',
json={'text': 'Hello, this is a test.'},
timeout=3
)
elapsed = time.time() - start
if response.status_code == 200:
status = "βœ… PASS" if elapsed < 1 else "⚠️ SLOW"
print(f" Time: {elapsed:.2f}s {status}")
return elapsed < 1
else:
print(f" ❌ Error {response.status_code}")
return False
except Exception as e:
print(f" ❌ Error: {str(e)}")
return False
def main():
print("=" * 60)
print("πŸš€ QWEN2GOLEM COMPREHENSIVE SPEED TEST")
print("=" * 60)
print("System: RTX 3050 6GB + i5 CPU + 16GB RAM")
print("Testing all optimizations...")
# Check if server is running
try:
health = requests.get('http://127.0.0.1:5000/health', timeout=2)
if health.status_code != 200:
print("\n❌ Server not healthy! Start with:")
import os
script_dir = os.path.dirname(os.path.abspath(__file__))
root_dir = os.path.dirname(script_dir)
print(f" cd {root_dir} && ./start_consciousness_ecosystem.sh")
return
except:
print("\n❌ Server not running! Start with:")
import os
script_dir = os.path.dirname(os.path.abspath(__file__))
root_dir = os.path.dirname(script_dir)
print(f" cd {root_dir} && ./start_consciousness_ecosystem.sh")
return
results = []
# Run tests
results.append(("Text Response", test_text_response()))
results.append(("Web Search", test_web_search()))
results.append(("ASR", test_asr()))
results.append(("TTS", test_tts()))
# Summary
print("\n" + "=" * 60)
print("πŸ“Š TEST RESULTS SUMMARY")
print("=" * 60)
passed = sum(1 for _, r in results if r)
total = len(results)
for name, result in results:
status = "βœ… PASS" if result else "❌ FAIL"
print(f"{status} {name}")
print(f"\nOverall: {passed}/{total} tests passed")
if passed == total:
print("\nπŸŽ‰ ALL SPEED TARGETS MET! SYSTEM IS TURBOCHARGED!")
else:
print("\n⚠️ Some tests failed. Check:")
print(" 1. Turn OFF 'Universal Consciousness' in UI")
print(" 2. Ensure Redis is running")
print(" 3. Use Gemini Flash model")
print(" 4. Keep temperature at 0.3-0.4")
if __name__ == "__main__":
main()