Skip to content

Add automatic benchmarking #3

Add automatic benchmarking

Add automatic benchmarking #3

Workflow file for this run

name: temp-bench
on:
push:
branches:
- develop
# paths: # With benchmarks set to re-run on any push to develop
# - docs/**
pull_request:
branches:
- develop
workflow_dispatch: # Allows manual triggering of the workflow
# This job installs dependencies, builds the book, and pushes it to `gh-pages`
jobs:
deploy-book:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# Install dependencies
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.13"
- name: Install dependencies
run: |
pip install -e ".[docs, develop]"
- name: Run benchmark
working-directory: ${{runner.workspace}}/floris/
run: |
ls -lah
cd benchmarks
pytest bench.py --benchmark-json output.json
# Store benchmark result and create the benchmark pages
- name: Store benchmark result
uses: benchmark-action/github-action-benchmark@v1
with:
name: Python Benchmark with pytest-benchmark
tool: 'pytest'
output-file-path: benchmarks/output.json
github-token: ${{ secrets.GITHUB_TOKEN }}
auto-push: true
gh-pages-branch: benches
# Add bench mark files to the gh-pages branch
- name: Add benchmark files to gh-pages
working-directory: ${{runner.workspace}}/floris/
run: |
ls -lah
git fetch origin benches
git checkout benches
cp -r dev/bench /tmp/dev/bench
git fetch origin gh-pages
git checkout gh-pages
cp -r /tmp/dev/bench ./dev/bench
git add dev
git commit -m "Add bench folder to gh-pages"
git push origin gh-pages
# # Fetch the gh-pages branch to get the benchmark files
# - name: Fetch benchmark files
# run: |
# # Fetch the gh-pages branch
# git fetch origin gh-pages:gh-pages
# # Create a temporary directory
# mkdir -p temp_bench
# # Checkout just the dev/bench directory from gh-pages
# git checkout gh-pages -- dev/bench || echo "No existing dev/bench directory"
# # Copy the files if they exist
# if [ -d "dev/bench" ]; then
# cp -r dev/bench/* temp_bench/
# fi
# # Return to original branch
# git checkout -
# # Copy benchmark files to the built documentation
# - name: Copy benchmark files to docs
# working-directory: ${{runner.workspace}}/floris/
# run: |
# mkdir -p docs/_build/html/dev/bench
# cp -r temp_bench/* docs/_build/html/dev/bench/ || echo "No benchmark files to copy"