File size: 1,589 Bytes
a45102f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env python3
import time
from model import AcoliModel

def performance_test():
    print("Loading model for performance test...")
    model = AcoliModel("./acoli-model")
    
    # Test texts
    test_texts = [
        "Acoli dwog ma con gi twero nwongo piny i ceng lok.",
        "Lapwony opoto i kom yat ma opore i wi dogola.",
        "Pii ma okelo ngom ma tye ka dwaro lweny i kom dano.",
        "Kit ma gitye ka twero bedo ki dano ma opore i wi piny.",
        "Yoo ma gitye ka twero nongo i kom dano ma tye i ceng."
    ] * 10  # Repeat to get more samples
    
    print(f"Testing with {len(test_texts)} texts...")
    
    # Test inference speed
    start_time = time.time()
    
    predictions = []
    for text in test_texts:
        prediction = model.predict(text)
        predictions.append(prediction)
    
    end_time = time.time()
    total_time = end_time - start_time
    
    # Calculate metrics
    avg_time_per_prediction = total_time / len(test_texts)
    predictions_per_second = len(test_texts) / total_time
    
    print(f"\n⏱️  Performance Results:")
    print(f"Total time: {total_time:.2f} seconds")
    print(f"Average time per prediction: {avg_time_per_prediction:.3f} seconds")
    print(f"Predictions per second: {predictions_per_second:.1f}")
    print(f"Total predictions: {len(test_texts)}")
    
    # Show some predictions
    print(f"\n🔍 Sample predictions:")
    for i in range(3):
        print(f"Text: {test_texts[i][:50]}...")
        print(f"Prediction: {predictions[i]}\n")

if __name__ == "__main__":
    performance_test()