We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2186900 commit 4a8bc01Copy full SHA for 4a8bc01
1 file changed
Mesa/Flocking/benchmark.py
@@ -5,9 +5,16 @@
5
import timeit
6
import gc
7
import statistics
8
+import random
9
-setup = f"""
10
-gc.enable()
+REPETITIONS = 3
11
+SEED = 12
12
+
13
+random.seed(SEED)
14
+a = []
15
+for i in range(0, REPETITIONS):
16
+ tt = timeit.Timer('runthemodel(flock)', setup=
17
+f"""gc.enable()
18
import os, sys
19
sys.path.insert(0, os.path.abspath("."))
20
@@ -21,13 +28,12 @@ def runthemodel(flock):
21
28
flock = BoidFlockers(
22
29
population=80000,
23
30
width=400,
24
- height=400
31
+ height=400,
32
+ seed={random.randint(0, 999999999)}
25
33
)
26
34
"""
27
-
-tt = timeit.Timer('runthemodel(flock)', setup=setup)
-SAMPLES=3
-a = tt.repeat(SAMPLES, 1)
35
+ )
36
+ a.append(tt.timeit(1))
37
print("Mesa Flocking times (ms):", list(map(lambda x: x * 1e3, a)))
38
print("Mesa Flocking (mean ms):", statistics.mean(a)*1e3)
39
0 commit comments