Skip to content

Commit 4a8bc01

Browse files
committed
seed mesa (untested)
1 parent 2186900 commit 4a8bc01

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

Mesa/Flocking/benchmark.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,16 @@
55
import timeit
66
import gc
77
import statistics
8+
import random
89

9-
setup = f"""
10-
gc.enable()
10+
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()
1118
import os, sys
1219
sys.path.insert(0, os.path.abspath("."))
1320
@@ -21,13 +28,12 @@ def runthemodel(flock):
2128
flock = BoidFlockers(
2229
population=80000,
2330
width=400,
24-
height=400
31+
height=400,
32+
seed={random.randint(0, 999999999)}
2533
)
2634
"""
27-
28-
tt = timeit.Timer('runthemodel(flock)', setup=setup)
29-
SAMPLES=3
30-
a = tt.repeat(SAMPLES, 1)
35+
)
36+
a.append(tt.timeit(1))
3137
print("Mesa Flocking times (ms):", list(map(lambda x: x * 1e3, a)))
3238
print("Mesa Flocking (mean ms):", statistics.mean(a)*1e3)
3339

0 commit comments

Comments
 (0)