|
|
|
|
|
import time |
|
|
from model import AcoliModel |
|
|
|
|
|
def performance_test(): |
|
|
print("Loading model for performance test...") |
|
|
model = AcoliModel("./acoli-model") |
|
|
|
|
|
|
|
|
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 |
|
|
|
|
|
print(f"Testing with {len(test_texts)} texts...") |
|
|
|
|
|
|
|
|
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 |
|
|
|
|
|
|
|
|
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)}") |
|
|
|
|
|
|
|
|
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() |