File size: 1,773 Bytes
33d3592
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
"""
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()