feat: add performance benchmarks with pytest-benchmark #3
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Benchmarks | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| workflow_dispatch: | |
| env: | |
| VTK_VERSION_MAJOR: 9 | |
| VTK_VERSION_MINOR: 5 | |
| VTK_VERSION_PATCH: 2 | |
| permissions: | |
| contents: write | |
| deployments: write | |
| jobs: | |
| benchmark: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install VTK | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y libvtk9-dev qtbase5-dev qt5-qmake libgl1-mesa-dev libglu1-mesa-dev freeglut3-dev | |
| - name: Set CMake path | |
| run: echo "CMAKE_PREFIX_PATH=/usr/lib/cmake/vtk" >> $GITHUB_ENV | |
| - uses: astral-sh/setup-uv@v4 | |
| with: | |
| python-version: "3.12" | |
| - name: Install dependencies | |
| run: uv sync -v | |
| - name: Run benchmarks | |
| run: | | |
| uv run pytest benchmarks/ \ | |
| --benchmark-only \ | |
| --benchmark-json=benchmark-results.json \ | |
| --benchmark-group-by=group \ | |
| --benchmark-sort=mean | |
| - name: Store benchmark result | |
| uses: benchmark-action/github-action-benchmark@v1 | |
| if: github.event_name != 'pull_request' | |
| with: | |
| tool: "pytest" | |
| output-file-path: benchmark-results.json | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| auto-push: true | |
| alert-threshold: "150%" | |
| comment-on-alert: true | |
| fail-on-alert: false | |
| - name: Compare benchmarks (PR only) | |
| uses: benchmark-action/github-action-benchmark@v1 | |
| if: github.event_name == 'pull_request' | |
| with: | |
| tool: "pytest" | |
| output-file-path: benchmark-results.json | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| auto-push: false | |
| alert-threshold: "150%" | |
| comment-on-alert: true | |
| fail-on-alert: false | |
| - name: Upload benchmark results | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: benchmark-results | |
| path: benchmark-results.json | |
| retention-days: 30 |