-
Notifications
You must be signed in to change notification settings - Fork 14
78 lines (69 loc) · 2.43 KB
/
benchmark.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
name: Python Benchmark
on:
pull_request:
concurrency:
group: benchmark-${{ github.ref }}
cancel-in-progress: true
defaults:
run:
working-directory: ./bindings/python
shell: bash
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ["ubuntu-22.04"]
python-version: ["3.10"]
fail-fast: false
steps:
- uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: '**/setup.cfg'
- name: Start MongoDB
uses: supercharge/[email protected]
with:
mongodb-version: 6.0
- name: Install libbson
run: |
LIBBSON_INSTALL_DIR=$(pwd)/libbson ./build-libbson.sh
- name: Install Python dependencies
run: |
python -m pip install -U pip
python -m pip install asv virtualenv
- name: Run benchmarks
run: |
set -eux
run_asv () {
if [ ! -e "asv.conf.json" ] ; then
git checkout refs/bm/pr asv.conf.json
git checkout refs/bm/pr benchmarks/__init__.py
git checkout refs/bm/pr benchmarks/benchmarks.py
fi
git show --no-patch --format="%H (%s)"
asv run -e --python=`which python` --set-commit-hash $(git rev-parse HEAD)
}
asv machine --yes
git fetch origin main:main
git update-ref refs/bm/pr HEAD
# We know this is a PR run. The branch is a GitHub refs/pull/*/merge ref, so
# the current target that this PR will be merged into is HEAD^1.
git update-ref refs/bm/merge-target $(git log -n 1 --pretty=format:"%H" main --)
git checkout --force refs/bm/pr --
# Install the library
LIBBSON_INSTALL_DIR=$(pwd)/libbson python -m pip install -e ".[test]"
run_asv
git checkout --force refs/bm/merge-target --
# Install the library
LIBBSON_INSTALL_DIR=$(pwd)/libbson python -m pip install -e ".[test]"
run_asv
- name: Compare benchmarks
run: |
asv compare refs/bm/merge-target refs/bm/pr --
- name: Fail if any benchmarks have slowed down too much
run: |
! asv compare --factor 1.2 --split refs/bm/merge-target refs/bm/pr | grep -q "got worse"