|
name: Backend benchmark |
|
|
|
on: |
|
push: |
|
branches: [main] |
|
pull_request: |
|
workflow_dispatch: |
|
|
|
permissions: |
|
contents: read |
|
|
|
jobs: |
|
compare-backends: |
|
runs-on: ubuntu-latest |
|
timeout-minutes: 30 |
|
steps: |
|
- uses: actions/checkout@v7 |
|
with: |
|
fetch-depth: 0 |
|
persist-credentials: false |
|
- uses: actions/setup-python@v7 |
|
with: |
|
python-version: "3.12" |
|
- name: Ensure Git 2.52 or newer |
|
run: | |
|
if ! dpkg --compare-versions "$(git version | awk '{print $3}')" ge 2.52; then |
|
sudo add-apt-repository --yes ppa:git-core/ppa |
|
sudo apt-get update |
|
sudo apt-get install --yes git |
|
fi |
|
- name: Prepare Rust for GixPython |
|
run: | |
|
rustup update stable |
|
rustup default stable |
|
echo "CARGO_TARGET_DIR=$RUNNER_TEMP/gix-target" >> "$GITHUB_ENV" |
|
- name: Cache GixPython builds |
|
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 |
|
with: |
|
path: | |
|
~/.cargo/registry |
|
~/.cargo/git |
|
${{ runner.temp }}/gix-target |
|
~/.cache/pip |
|
key: benchmark-gix-${{ runner.os }}-${{ hashFiles('gix-requirements.txt') }} |
|
- name: Install separate backends with the same interpreter |
|
run: | |
|
python -m venv .bench-cli |
|
python -m venv .bench-gix |
|
.bench-cli/bin/python -m pip install . -r test/performance/benchmark-requirements.txt |
|
.bench-gix/bin/python -m pip install '.[gix]' -r test/performance/benchmark-requirements.txt |
|
- name: Prepare the shared read-only benchmark fixture |
|
run: | |
|
.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" |
|
mkdir benchmark-results |
|
- name: Measure GixPython operations, opening and discovery first |
|
env: |
|
GIT_PYTHON_BACKEND: gix |
|
run: | |
|
.bench-gix/bin/python -m test.performance.bench_repository \ |
|
--repo "$BENCH_REPO" --expect-backend gix -o benchmark-results/gix.json |
|
- name: Measure CLI operations, opening and discovery |
|
env: |
|
GIT_PYTHON_BACKEND: cli |
|
run: | |
|
.bench-cli/bin/python -m test.performance.bench_repository \ |
|
--repo "$BENCH_REPO" --expect-backend cli -o benchmark-results/cli.json |
|
- name: Check parity and publish comparison |
|
run: | |
|
.bench-gix/bin/python -m test.performance.compare_backends \ |
|
benchmark-results/cli.json benchmark-results/gix.json \ |
|
--cli-budget test/performance/cli-budget.json > benchmark-results/comparison.md |
|
cat benchmark-results/comparison.md >> "$GITHUB_STEP_SUMMARY" |
|
.bench-gix/bin/python -m pyperf compare_to \ |
|
benchmark-results/cli.json benchmark-results/gix.json --table --table-format md \ |
|
>> "$GITHUB_STEP_SUMMARY" |
|
- name: Retain raw timings and comparison |
|
if: always() |
|
uses: actions/upload-artifact@v7 |
|
with: |
|
name: backend-benchmark |
|
path: benchmark-results/ |