Skip to content

Commit 25a4a36

Browse files
committed
Refactor Python benchmarking to use BenchmarkTools
1 parent 125f8b9 commit 25a4a36

1 file changed

Lines changed: 6 additions & 11 deletions

File tree

docs/src/guides/benchmarking.md

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -482,18 +482,13 @@ We benchmark both libraries across different input sizes:
482482
# Python benchmark
483483
py_func, py_kwargs = solposx_algorithms[algo_name]
484484

485-
# Time the Python function (5 runs, take median)
486-
py_elapsed = Float64[]
487-
for _ in 1:5
488-
t_start = time()
489-
if isempty(py_kwargs)
490-
py_func(py_times_idx, lat, lon)
491-
else
492-
py_func(py_times_idx, lat, lon; py_kwargs...)
493-
end
494-
push!(py_elapsed, (time() - t_start) * 1000) # Convert to ms
485+
# Benchmark Python function using BenchmarkTools
486+
if isempty(py_kwargs)
487+
py_bench = @benchmark $py_func($py_times_idx, $lat, $lon) samples=5 evals=1
488+
else
489+
py_bench = @benchmark $py_func($py_times_idx, $lat, $lon; $py_kwargs...) samples=5 evals=1
495490
end
496-
python_time_ms = median(py_elapsed)
491+
python_time_ms = median(py_bench.times) / 1e6
497492

498493
speedup = python_time_ms / julia_time_ms
499494

0 commit comments

Comments
 (0)