prelington commited on
Commit
a45102f
·
verified ·
1 Parent(s): 91ff650

Create performance_test.py

Browse files
Files changed (1) hide show
  1. performance_test.py +48 -0
performance_test.py ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ import time
3
+ from model import AcoliModel
4
+
5
+ def performance_test():
6
+ print("Loading model for performance test...")
7
+ model = AcoliModel("./acoli-model")
8
+
9
+ # Test texts
10
+ test_texts = [
11
+ "Acoli dwog ma con gi twero nwongo piny i ceng lok.",
12
+ "Lapwony opoto i kom yat ma opore i wi dogola.",
13
+ "Pii ma okelo ngom ma tye ka dwaro lweny i kom dano.",
14
+ "Kit ma gitye ka twero bedo ki dano ma opore i wi piny.",
15
+ "Yoo ma gitye ka twero nongo i kom dano ma tye i ceng."
16
+ ] * 10 # Repeat to get more samples
17
+
18
+ print(f"Testing with {len(test_texts)} texts...")
19
+
20
+ # Test inference speed
21
+ start_time = time.time()
22
+
23
+ predictions = []
24
+ for text in test_texts:
25
+ prediction = model.predict(text)
26
+ predictions.append(prediction)
27
+
28
+ end_time = time.time()
29
+ total_time = end_time - start_time
30
+
31
+ # Calculate metrics
32
+ avg_time_per_prediction = total_time / len(test_texts)
33
+ predictions_per_second = len(test_texts) / total_time
34
+
35
+ print(f"\n⏱️ Performance Results:")
36
+ print(f"Total time: {total_time:.2f} seconds")
37
+ print(f"Average time per prediction: {avg_time_per_prediction:.3f} seconds")
38
+ print(f"Predictions per second: {predictions_per_second:.1f}")
39
+ print(f"Total predictions: {len(test_texts)}")
40
+
41
+ # Show some predictions
42
+ print(f"\n🔍 Sample predictions:")
43
+ for i in range(3):
44
+ print(f"Text: {test_texts[i][:50]}...")
45
+ print(f"Prediction: {predictions[i]}\n")
46
+
47
+ if __name__ == "__main__":
48
+ performance_test()