Skip to content

Commit fbb87d0

Browse files
committed
Add benchmark
1 parent 95a752f commit fbb87d0

2 files changed

Lines changed: 33 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: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
start_time = 0.0
11+
profiler = cProfile.Profile()
12+
for i in range(10):
13+
if i==3:
14+
profiler.enable()
15+
start_time = time.time()
16+
17+
print(f"Iteration {i}")
18+
delta.update()
19+
20+
end_time = time.time()
21+
22+
profiler.disable()
23+
profiler.print_stats()
24+
25+
print(f"Total time = {end_time - start_time}")
26+
27+
my_date = datetime.now()
28+
stats = pstats.Stats(profiler)
29+
stats.dump_stats(f"bench_result_{my_date.isoformat()}.prof")
30+
delta.finalize()
31+
32+
# 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)