File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55import timeit
66import gc
77import statistics
8+ import random
89
9- setup = f"""
10+ REPETITIONS = 3
11+ SEED = 12
12+
13+ random .seed (SEED )
14+ a = []
15+ for i in range (0 , REPETITIONS ):
16+ setup = f"""
1017gc.enable()
1118import os, sys
1219sys.path.insert(0, os.path.abspath("."))
@@ -21,13 +28,12 @@ def runthemodel(flock):
2128flock = 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+ tt = timeit .Timer ('runthemodel(flock)' , setup = setup )
36+ a .append (tt .timeit (1 ))
3137print ("Mesa Flocking times (ms):" , list (map (lambda x : x * 1e3 , a )))
3238print ("Mesa Flocking (mean ms):" , statistics .mean (a )* 1e3 )
3339
Original file line number Diff line number Diff line change 33import timeit
44import gc
55import statistics
6+ import random
7+
8+ REPETITIONS = 3
9+ SEED = 12
610
7- setup = f"""
11+ random .seed (SEED )
12+ a = []
13+ for i in range (0 , REPETITIONS ):
14+ setup = f"""
815gc.enable()
916import os, sys
1017sys.path.insert(0, os.path.abspath("."))
1118
1219from model import SchellingModel
1320
14- import random
15- random.seed(2)
16-
1721def runthemodel(schelling):
1822 for i in range(0, 100):
1923 schelling.step()
2024
2125schelling = SchellingModel(
2226 height=500,
2327 width=500,
24- density=0.8
28+ density=0.8,
29+ seed={ random .randint (0 , 999999999 )}
2530)
2631"""
27-
28- tt = timeit .Timer ('runthemodel(schelling)' , setup = setup )
29- SAMPLES = 3
30- a = tt .repeat (SAMPLES , 1 )
32+ tt = timeit .Timer ('runthemodel(schelling)' , setup = setup )
33+ a .append (tt .timeit (1 ))
3134print ("Mesa schelling times (ms):" , list (map (lambda x : x * 1e3 , a )))
3235print ("Mesa schelling (mean ms):" , statistics .mean (a )* 1e3 )
3336
You can’t perform that action at this time.
0 commit comments