|
| 1 | +name: Backend benchmark |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + pull_request: |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: read |
| 11 | + |
| 12 | +jobs: |
| 13 | + compare-backends: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + timeout-minutes: 30 |
| 16 | + steps: |
| 17 | + - uses: actions/checkout@v7 |
| 18 | + with: |
| 19 | + fetch-depth: 0 |
| 20 | + persist-credentials: false |
| 21 | + - uses: actions/setup-python@v7 |
| 22 | + with: |
| 23 | + python-version: "3.12" |
| 24 | + - name: Ensure Git 2.52 or newer |
| 25 | + run: | |
| 26 | + if ! dpkg --compare-versions "$(git version | awk '{print $3}')" ge 2.52; then |
| 27 | + sudo add-apt-repository --yes ppa:git-core/ppa |
| 28 | + sudo apt-get update |
| 29 | + sudo apt-get install --yes git |
| 30 | + fi |
| 31 | + - name: Prepare Rust for GixPython |
| 32 | + run: | |
| 33 | + rustup update stable |
| 34 | + rustup default stable |
| 35 | + echo "CARGO_TARGET_DIR=$RUNNER_TEMP/gix-target" >> "$GITHUB_ENV" |
| 36 | + - name: Cache GixPython builds |
| 37 | + uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 |
| 38 | + with: |
| 39 | + path: | |
| 40 | + ~/.cargo/registry |
| 41 | + ~/.cargo/git |
| 42 | + ${{ runner.temp }}/gix-target |
| 43 | + ~/.cache/pip |
| 44 | + key: benchmark-gix-${{ runner.os }}-${{ hashFiles('gix-requirements.txt') }} |
| 45 | + - name: Install separate backends with the same interpreter |
| 46 | + run: | |
| 47 | + python -m venv .bench-cli |
| 48 | + python -m venv .bench-gix |
| 49 | + .bench-cli/bin/python -m pip install . -r test/performance/benchmark-requirements.txt |
| 50 | + .bench-gix/bin/python -m pip install '.[gix]' -r test/performance/benchmark-requirements.txt |
| 51 | + - name: Prepare the shared read-only benchmark fixture |
| 52 | + run: | |
| 53 | + .bench-cli/bin/python -c 'from pathlib import Path; from gix import testtools; print("BENCH_REPO=" + str((testtools.scripted_fixture_read_only_with_args("benchmark.sh", [str(Path.cwd())]) / "repo").resolve()))' >> "$GITHUB_ENV" |
| 54 | + mkdir benchmark-results |
| 55 | + - name: Measure GixPython operations, opening and discovery first |
| 56 | + env: |
| 57 | + GIT_PYTHON_BACKEND: gix |
| 58 | + run: | |
| 59 | + .bench-gix/bin/python -m test.performance.bench_repository \ |
| 60 | + --repo "$BENCH_REPO" --expect-backend gix -o benchmark-results/gix.json |
| 61 | + - name: Measure CLI operations, opening and discovery |
| 62 | + env: |
| 63 | + GIT_PYTHON_BACKEND: cli |
| 64 | + run: | |
| 65 | + .bench-cli/bin/python -m test.performance.bench_repository \ |
| 66 | + --repo "$BENCH_REPO" --expect-backend cli -o benchmark-results/cli.json |
| 67 | + - name: Check parity and publish comparison |
| 68 | + run: | |
| 69 | + .bench-gix/bin/python -m test.performance.compare_backends \ |
| 70 | + benchmark-results/cli.json benchmark-results/gix.json \ |
| 71 | + --cli-budget test/performance/cli-budget.json > benchmark-results/comparison.md |
| 72 | + cat benchmark-results/comparison.md >> "$GITHUB_STEP_SUMMARY" |
| 73 | + .bench-gix/bin/python -m pyperf compare_to \ |
| 74 | + benchmark-results/cli.json benchmark-results/gix.json --table --table-format md \ |
| 75 | + >> "$GITHUB_STEP_SUMMARY" |
| 76 | + - name: Retain raw timings and comparison |
| 77 | + if: always() |
| 78 | + uses: actions/upload-artifact@v7 |
| 79 | + with: |
| 80 | + name: backend-benchmark |
| 81 | + path: benchmark-results/ |
0 commit comments