Skip to content

Benchmarks

Benchmarks #1775

# This workflow periodically runs the benchmarks suite in benchmarks/
# using asv and publish the results, effectively updating
# the display website hosted in the pybamm-bench repo
# Steps:
# - Benchmark all commits since the last one that was benchmarked
# - Push results to pybamm-bench repo
# - Publish website
name: Benchmarks
on:
# Every day at 3 am UTC
schedule:
- cron: "0 3 * * *"
# Make it possible to trigger the
# workflow manually
workflow_dispatch:
permissions: {}
env:
PYBAMM_DISABLE_TELEMETRY: "true"
jobs:
benchmarks:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
persist-credentials: false
- name: Set up Python 3.12
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
with:
python-version: 3.12
- name: Install Linux system dependencies
run: |
sudo apt-get update
sudo apt-get install gfortran gcc libopenblas-dev
- uses: astral-sh/setup-uv@85856786d1ce8acfbcc2f13a5f3fbd6b938f9f41 # v7.1.2
with:
version: "latest"
enable-cache: true
- name: Install python dependencies
run: uv pip install --system asv
- name: Run benchmarks
run: |
asv machine --machine "GitHubRunner"
asv run --machine "GitHubRunner" NEW --show-stderr -v
- name: Upload results as artifact
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
with:
name: asv_periodic_results
path: results
if-no-files-found: error
publish-results:
if: github.repository == 'pybamm-team/PyBaMM'
name: Push and publish results
needs: benchmarks
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Set up Python 3.12
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
with:
python-version: 3.12
- name: Install asv
run: pip install asv
- name: Checkout pybamm-bench repo
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
repository: pybamm-team/pybamm-bench
token: ${{ secrets.BENCH_PAT }}
persist-credentials: false
- name: Download results artifact(s)
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
with:
path: results
merge-multiple: true
- name: Copy new results and push to pybamm-bench repo
env:
PUSH_BENCH_EMAIL: ${{ secrets.PUSH_BENCH_EMAIL }}
PUSH_BENCH_NAME: ${{ secrets.PUSH_BENCH_NAME }}
run: |
git config --global user.email "$PUSH_BENCH_EMAIL"
git config --global user.name "$PUSH_BENCH_NAME"
git add results
git commit -am "Add new results"
git push
- name: Publish results
run: |
asv publish
git fetch origin gh-pages:gh-pages
asv gh-pages