Skip to content

Commit 35a462b

Browse files
committed
Add benchmark
1 parent 95a752f commit 35a462b

2 files changed

Lines changed: 32 additions & 0 deletions

File tree

benchmark/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.prof

benchmark/benchmark.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import cProfile
2+
import pstats
3+
import time
4+
from datetime import datetime
5+
6+
import pyDeltaRCM
7+
8+
delta = pyDeltaRCM.DeltaModel(save_eta_figs=False)
9+
10+
profiler = cProfile.Profile()
11+
for i in range(10):
12+
if i==3:
13+
start_time = time.time()
14+
profiler.enable()
15+
16+
print(f"Iteration {i}")
17+
delta.update()
18+
19+
end_time = time.time()
20+
21+
profiler.disable()
22+
profiler.print_stats()
23+
24+
print(f"Total time = {end_time - start_time}")
25+
26+
my_date = datetime.now()
27+
stats = pstats.Stats(profiler)
28+
stats.dump_stats(f"bench_result_{my_date.isoformat()}.prof")
29+
delta.finalize()
30+
31+
# Results can be plotted with, eg, `flameprof -o /z/out.svg bench_result_2022-05-23T10:39:22.808217.prof`

0 commit comments

Comments
 (0)