Skip to content

Commit 6c2a89e

Browse files
Add CI job for benchmarking
Co-authored-by: Brandon T. Willard <[email protected]>
1 parent 0a242f2 commit 6c2a89e

File tree

1 file changed

+54
-1
lines changed

1 file changed

+54
-1
lines changed

.github/workflows/test.yml

+54-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ on:
44
push:
55
branches:
66
- main
7-
- checks
87
pull_request:
98
branches:
109
- main
@@ -148,6 +147,60 @@ jobs:
148147
name: coverage
149148
path: coverage/coverage-${{ steps.matrix-id.outputs.id }}.xml
150149

150+
benchmarks:
151+
name: "Benchmarks"
152+
needs:
153+
- changes
154+
- style
155+
runs-on: ubuntu-latest
156+
if: ${{ needs.changes.outputs.changes == 'true' && needs.style.result == 'success' }}
157+
strategy:
158+
fail-fast: true
159+
steps:
160+
- uses: actions/checkout@v3
161+
with:
162+
fetch-depth: 0
163+
- name: Set up Python 3.9
164+
uses: conda-incubator/setup-miniconda@v2
165+
with:
166+
mamba-version: "*"
167+
channels: conda-forge,defaults
168+
channel-priority: true
169+
python-version: 3.9
170+
auto-update-conda: true
171+
- name: Install dependencies
172+
shell: bash -l {0}
173+
run: |
174+
mamba install --yes -q -c conda-forge "python~=${PYTHON_VERSION}=*_cpython" mkl numpy scipy pip mkl-service cython pytest "numba>=0.55" numba-scipy jax jaxlib pytest-benchmark
175+
pip install -e ./
176+
mamba list && pip freeze
177+
python -c 'import pytensor; print(pytensor.config.__str__(print_doc=False))'
178+
python -c 'import pytensor; assert(pytensor.config.blas__ldflags != "")'
179+
env:
180+
PYTHON_VERSION: 3.9
181+
- name: Download previous benchmark data
182+
uses: actions/cache@v1
183+
with:
184+
path: ./cache
185+
key: ${{ runner.os }}-benchmark
186+
- name: Run benchmarks
187+
shell: bash -l {0}
188+
run: |
189+
export PYTENSOR_FLAGS=mode=FAST_COMPILE,warn__ignore_bug_before=all,on_opt_error=raise,on_shape_error=raise,gcc__cxxflags=-pipe
190+
python -m pytest --runslow --benchmark-only --benchmark-json output.json
191+
- name: Store benchmark result
192+
uses: benchmark-action/github-action-benchmark@v1
193+
with:
194+
name: Python Benchmark with pytest-benchmark
195+
tool: 'pytest'
196+
output-file-path: output.json
197+
external-data-json-path: ./cache/benchmark-data.json
198+
alert-threshold: '200%'
199+
github-token: ${{ secrets.GITHUB_TOKEN }}
200+
comment-on-alert: ${{ github.event_name == 'push' }}
201+
fail-on-alert: true
202+
auto-push: false
203+
151204
all-checks:
152205
if: ${{ always() }}
153206
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)