| 1 |
name: benchmark |
| 2 |
|
| 3 |
"on": |
| 4 |
push: |
| 5 |
branches: |
| 6 |
- main |
| 7 |
- dev |
| 8 |
- deps |
| 9 |
pull_request: |
| 10 |
branches: |
| 11 |
- main |
| 12 |
workflow_dispatch: |
| 13 |
inputs: |
| 14 |
ref: |
| 15 |
description: (optional) ref to benchmark |
| 16 |
|
| 17 |
env: |
| 18 |
FORCE_COLOR: "1" |
| 19 |
PYTHONHASHSEED: "42" |
| 20 |
BASELINE_URL: https://github.com/jab/bidict/releases/download/microbenchmarks/GHA-linux-cachegrind-x86_64-CPython-3.12.2-baseline.json |
| 21 |
|
| 22 |
jobs: |
| 23 |
benchmark: |
| 24 |
runs-on: ubuntu-latest |
| 25 |
steps: |
| 26 |
- name: install valgrind |
| 27 |
uses: awalsh128/cache-apt-pkgs-action@44c33b32f808cdddd5ac0366d70595ed63661ed8 |
| 28 |
with: |
| 29 |
packages: valgrind |
| 30 |
- name: check out source |
| 31 |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 |
| 32 |
with: |
| 33 |
fetch-depth: 0 |
| 34 |
- name: set up Python |
| 35 |
uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c |
| 36 |
with: |
| 37 |
# Pin to micro-release for better reproducibility. |
| 38 |
# When upgrading to a new Python version, remember to upload new associated baseline |
| 39 |
# benchmark results here: https://github.com/jab/bidict/releases/edit/microbenchmarks |
| 40 |
python-version: '3.12.2' |
| 41 |
cache: pip |
| 42 |
cache-dependency-path: dev-deps/python3.12/test.txt |
| 43 |
- name: install PyPI dependencies |
| 44 |
run: | |
| 45 |
python -m pip install -U pip setuptools wheel |
| 46 |
python -m pip install -r dev-deps/python3.12/test.txt |
| 47 |
- name: install the version of bidict to benchmark |
| 48 |
run: | |
| 49 |
git checkout ${{ github.event.inputs.ref || github.sha }} |
| 50 |
pip install . |
| 51 |
# restore the current revision so we use its version of tests/microbenchmarks.py |
| 52 |
git checkout ${{ github.sha }} |
| 53 |
# move aside the 'bidict' subdirectory to make sure we always import the installed version |
| 54 |
mv -v bidict src |
| 55 |
- name: download baseline benchmark results |
| 56 |
run: | |
| 57 |
curl -Lso baseline.json "$BASELINE_URL" |
| 58 |
line1=$(head -n1 baseline.json) |
| 59 |
[ "$line1" = "{" ] |
| 60 |
- name: benchmark and compare to baseline |
| 61 |
run: | |
| 62 |
./cachegrind.py pytest -n0 \ |
| 63 |
--benchmark-enable \ |
| 64 |
--benchmark-autosave \ |
| 65 |
--benchmark-compare=baseline.json \ |
| 66 |
tests/microbenchmarks.py |
| 67 |
- name: archive benchmark results |
| 68 |
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 |
| 69 |
with: |
| 70 |
name: microbenchmark results |
| 71 |
path: .benchmarks |
| 72 |
if-no-files-found: error |
| 73 |
|
| 74 |
permissions: |
| 75 |
contents: read |