Skip to content

Commit

Permalink
seed mesa (untested)
Browse files Browse the repository at this point in the history
  • Loading branch information
Robadob committed Dec 11, 2023
1 parent 2186900 commit 4a8bc01
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions Mesa/Flocking/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,16 @@
import timeit
import gc
import statistics
import random

setup = f"""
gc.enable()
REPETITIONS = 3
SEED = 12

random.seed(SEED)
a = []
for i in range(0, REPETITIONS):
tt = timeit.Timer('runthemodel(flock)', setup=
f"""gc.enable()
import os, sys
sys.path.insert(0, os.path.abspath("."))
Expand All @@ -21,13 +28,12 @@ def runthemodel(flock):
flock = BoidFlockers(
population=80000,
width=400,
height=400
height=400,
seed={random.randint(0, 999999999)}
)
"""

tt = timeit.Timer('runthemodel(flock)', setup=setup)
SAMPLES=3
a = tt.repeat(SAMPLES, 1)
)
a.append(tt.timeit(1))
print("Mesa Flocking times (ms):", list(map(lambda x: x * 1e3, a)))
print("Mesa Flocking (mean ms):", statistics.mean(a)*1e3)

0 comments on commit 4a8bc01

Please sign in to comment.