Profiling givp¶
When investigating performance regressions or proposing optimizations to the
hot path (_neighborhood_*, local_search_vnd, _run_grasp_loop), please
attach a profile so reviewers can verify the impact.
Quick CPU profile with py-spy¶
py-spy is a sampling profiler that
attaches to a running Python process without instrumentation overhead.
pip install py-spy
py-spy record -o profile.svg -- \
python -m pytest benchmarks/ --benchmark-only -k "sphere and 30"
Open profile.svg in a browser to inspect the flamegraph.
Line-level profile with scalene¶
scalene reports CPU and
memory usage per line, which is useful for spotting accidental allocations
in the hot path.
Reproducible benchmark runs¶
The repository ships a pytest-benchmark suite under benchmarks/. Use
--benchmark-autosave to compare runs over time:
pytest benchmarks/ --benchmark-only --benchmark-autosave
pytest-benchmark compare 0001 0002 --columns=mean,stddev,ops
Pin the master RNG via the public seed= parameter to make timing
comparisons deterministic across runs.
Julia benchmarks¶
The Julia port includes a BenchmarkTools.jl-based benchmark suite under
julia/benchmarks/. It covers four classic test functions (sphere,
rosenbrock, rastrigin, ackley) at dimensions 5 and 10:
Results are saved to julia/benchmarks/results.json. On subsequent runs, the
script automatically compares against the previous results and flags
regressions (>10% time increase).