Skip to content

Commit ec608ea

Browse files
committed
benchmark: Move creation of objects out of the hot path
This reduces the benchmark time by about 4x. Signed-off-by: Leandro Lucarella <[email protected]>
1 parent fcf8e60 commit ec608ea

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

benchmarks/timeseries/resampling.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,10 @@ def _benchmark_resampling_helper(resamples: int, samples: int) -> None:
3838

3939
def _do_work() -> None:
4040
nonlocal now
41+
delta = timedelta(seconds=1 / samples)
4142
for _n_resample in range(resamples):
4243
for _n_sample in range(samples):
43-
now = now + timedelta(seconds=1 / samples)
44+
now = now + delta
4445
helper.add_sample((now, 0.0))
4546
helper.resample(now)
4647

0 commit comments

Comments
 (0)