@@ -35,15 +35,37 @@ def test_gtp():
3535
3636
3737def test_ballpred ():
38- print ("Testing BallPrediction" )
38+ print ("Testing 10s BallPrediction" )
3939
4040 times = []
4141
4242 ballPred = flat .BallPrediction ([flat .PredictionSlice (1 ) for _ in range (120 * 10 )])
4343
4444 print (len (ballPred .pack ()))
4545
46- for _ in range (100_000 ):
46+ for _ in range (40_000 ):
47+ start = time_ns ()
48+
49+ packed = ballPred .pack ()
50+ flat .BallPrediction .unpack (packed )
51+
52+ times .append (time_ns () - start )
53+
54+ print (f"Total time: { sum (times ) / 1_000_000_000 :.3f} s" )
55+ avg_time_ns = sum (times ) / len (times )
56+ print (f"Average time per: { avg_time_ns / 1000 :.1f} us" )
57+ print (f"Minimum time per: { min (times ) / 1000 :.1f} us" )
58+
59+ print ()
60+ print ("Testing 6s BallPrediction" )
61+
62+ times = []
63+
64+ ballPred = flat .BallPrediction ([flat .PredictionSlice (1 ) for _ in range (120 * 6 )])
65+
66+ print (len (ballPred .pack ()))
67+
68+ for _ in range (40_000 ):
4769 start = time_ns ()
4870
4971 packed = ballPred .pack ()
@@ -72,6 +94,8 @@ def find_slice_at_time(ball_prediction: flat.BallPrediction, game_time: float):
7294
7395
7496def test_loop ():
97+ print ("Testing access times" )
98+
7599 ballPred = flat .BallPrediction ([flat .PredictionSlice (1 ) for _ in range (120 * 6 )])
76100
77101 start = time_ns ()
@@ -94,6 +118,7 @@ def test_loop():
94118
95119 times .append (time_ns () - start )
96120
121+ print ()
97122 print (f"Total time: { sum (times ) / 1_000_000_000 :.3f} s" )
98123 avg_time_ns = sum (times ) / len (times )
99124 print (f"Average time per: { avg_time_ns / 1000 :.1f} us" )
@@ -107,6 +132,7 @@ def test_loop():
107132
108133 times .append (time_ns () - start )
109134
135+ print ()
110136 print (f"Total time: { sum (times ) / 1_000_000_000 :.3f} s" )
111137 avg_time_ns = sum (times ) / len (times )
112138 print (f"Average time per: { avg_time_ns / 1000 :.1f} us" )
@@ -120,15 +146,16 @@ def test_loop():
120146
121147 times .append (time_ns () - start )
122148
149+ print ()
123150 print (f"Total time: { sum (times ) / 1_000_000_000 :.3f} s" )
124151 avg_time_ns = sum (times ) / len (times )
125152 print (f"Average time per: { avg_time_ns / 1000 :.1f} us" )
126153 print (f"Minimum time per: { min (times ) / 1000 :.1f} us" )
127154
128155
129156if __name__ == "__main__" :
130- test_gtp ()
131- print ()
157+ # test_gtp()
158+ # print()
132159 test_ballpred ()
133160 print ()
134161 test_loop ()
0 commit comments