Skip to content

Benchmarking

Benchmarking #3

name: Benchmark Checks
on:
# This workflow checks whether the benchmark code can be installed and
# started on the supported GitHub-hosted runners. It is a smoke check, not a
# performance benchmark suite.
pull_request:
branches:
- "main"
paths:
- ".github/workflows/benchmark-readiness.yml"
- "asv*.json"
- "benchmarks/**"
- "pyproject.toml"
push:
branches:
- "main"
paths:
- ".github/workflows/benchmark-readiness.yml"
- "asv*.json"
- "benchmarks/**"
- "pyproject.toml"
workflow_dispatch:
permissions:
contents: read
jobs:
benchmark_asv_existing_env:
name: ASV smoke on ${{ matrix.os }} py3.14
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- windows-latest
- macos-latest
- macos-15-intel
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
fetch-depth: 0
- uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
with:
python-version: "3.14"
- name: Install benchmark smoke dependencies
run: |
python -m pip install --upgrade pip
python -m pip install \
asv \
emcee \
"gstools-cython>=1,<2" \
hankel \
meshio \
"numpy==2.3.2" \
pyevtk \
"scipy==1.16.1"
python benchmarks/tools/install_pyproject_extras.py rust
python -m pip install --no-deps --editable .
- name: Configure ASV machine
run: |
# existing environments still need a machine profile for ASV result
# metadata. --yes keeps the command non-interactive in CI.
asv machine --yes
- name: Write ASV smoke config for checked-out commit
run: |
# With -E existing, ASV cannot receive a range like HEAD^!. If no
# range is supplied, ASV resolves the configured branches. PR
# checkouts do not necessarily have a local "main" branch, so this
# temporary config points ASV at the exact checked-out commit.
python - <<'PY'
import json
import os
from pathlib import Path
config = json.loads(Path("asv.conf.json").read_text())
config["branches"] = [os.environ["GITHUB_SHA"]]
Path("asv.ci-existing.json").write_text(json.dumps(config, indent=2))
PY
- name: Run ASV smoke check in existing environment
env:
GSTOOLS_BENCHMARK_THREADS: "1"
GSTOOLS_BENCHMARK_BACKENDS: "cython_fallback,rust_core"
run: |
# -E existing uses the Python environment prepared above. Existing
# environments cannot accept a commit range, so the checked-out
# commit is recorded explicitly.
ASV_SMOKE_BENCHMARK="benchmark_two_point_statistics.VariogramBenchmarks.time_variogram_estimate"
asv run \
--config asv.ci-existing.json \
-E existing \
--set-commit-hash "$GITHUB_SHA" \
--no-pull \
--quick \
--bench "$ASV_SMOKE_BENCHMARK" \
--show-stderr
benchmark_parallel_readiness:
name: Parallel readiness on ${{ matrix.os }} py3.14
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- windows-latest
- macos-latest
- macos-15-intel
defaults:
run:
shell: bash -el {0}
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- uses: conda-incubator/setup-miniconda@fc2d68f6413eb2d87b895e92f8584b5b94a10167 # v3
with:
activate-environment: gstools-benchmark-readiness
python-version: "3.14"
channels: conda-forge
conda-remove-defaults: true
- name: Install parallel readiness dependencies
run: |
conda install -n gstools-benchmark-readiness -y -c conda-forge \
emcee \
gstools-cython \
hankel \
meshio \
"numpy=2.3.2" \
pip \
pyevtk \
"scipy=1.16.1"
conda run -n gstools-benchmark-readiness python \
benchmarks/tools/install_pyproject_extras.py rust
conda run -n gstools-benchmark-readiness python -m pip install \
--no-deps --editable .
- name: Check Cython OpenMP and Rust backend readiness
run: |
conda run -n gstools-benchmark-readiness python \
benchmarks/tools/check_backend_parallel_ready.py --verbose