-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_performance.py
52 lines (40 loc) · 999 Bytes
/
test_performance.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
"""
Check performance
"""
import sciris as sc
import rotaABM as rabm
N = 5_000
timelimit = 30
kwargs = dict(N=N, timelimit=timelimit)
def update_performance(save=False):
sc.heading('Updating performance')
filename = 'test_performance.json'
T = sc.timer()
rota = rabm.RotaABM(**kwargs)
rota.run()
T.toc()
string = f'{T.elapsed:0.2f}'
data = dict(time=string)
if save:
sc.savejson(filename, data)
print(data)
return
def profile():
sc.heading('Running sc.profile')
rota = rabm.RotaABM(**kwargs)
prf = sc.profile(rota.run, follow=rota.integrate)
return prf
def cprofile():
sc.heading('Running sc.cprofile')
with sc.cprofile() as cpr:
rota = rabm.RotaABM(**kwargs, verbose=False)
rota.run()
return cpr
if __name__ == '__main__':
save = 0
do_profile = 1
if save or not do_profile:
update_performance(save=save)
else:
prf = profile()
cpr = cprofile()