syncmaster3 / performance_test.py
aseelflihan's picture
move actual project files into root folder
1138072
Raw History Blame Contribute Delete
1.77 kB
"""
Performance Test for SyncMaster
اختبار أداء التطبيق
"""
import time
import requests
import threading
def test_load_time(url, test_name):
"""Test page load time"""
try:
start = time.time()
response = requests.get(url, timeout=10)
end = time.time()
load_time = end - start
status = response.status_code
print(f"🧪 {test_name}:")
print(f" ⏱️ Load Time: {load_time:.3f} seconds")
print(f" 📊 Status: {status}")
print(f" ✅ {'FAST' if load_time < 0.5 else 'SLOW' if load_time > 1.0 else 'OK'}")
print()
return load_time, status
except Exception as e:
print(f"❌ {test_name} failed: {e}")
return None, None
def run_performance_tests():
"""Run comprehensive performance tests"""
print("🚀 SyncMaster Performance Test")
print("=" * 40)
# Test multiple requests to see consistency
tests = [
("First Load", "http://localhost:5050"),
("Second Load", "http://localhost:5050"),
("Third Load", "http://localhost:5050"),
("Recorder API", "http://localhost:5001/record")
]
results = []
for test_name, url in tests:
load_time, status = test_load_time(url, test_name)
if load_time:
results.append(load_time)
time.sleep(0.5) # Small delay between tests
if results:
avg_time = sum(results) / len(results)
print(f"📊 Average Load Time: {avg_time:.3f} seconds")
print(f"🎯 Performance Rating: {'EXCELLENT' if avg_time < 0.2 else 'GOOD' if avg_time < 0.5 else 'NEEDS IMPROVEMENT'}")
return results
if __name__ == "__main__":
run_performance_tests()