cog3pio 0.1.0

Cloud-optimized GeoTIFF ... Parallel I/O
Documentation
# Run performance benchmarks
#
# Continuous benchmarking with CodSpeed. Measures the execution speed of Rust benchmarks
# via cargo-codspeed, and Python tests marked with @pytest.mark.benchmark decorator.

name: Benchmarks

on:
  # Run on pushes to the main branch
  push:
    branches: [main]
  # Run on pull requests
  pull_request:
    types: [opened, reopened, synchronize]
  # `workflow_dispatch` allows CodSpeed to trigger backtest
  # performance analysis in order to generate initial data.
  workflow_dispatch:

env:
  CARGO_TERM_COLOR: always

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

permissions: {}

jobs:
  rust-benchmarks:
    name: "Run Rust benchmarks"
    runs-on: ubuntu-24.04
    container:
      image: ghcr.io/osgeo/gdal:ubuntu-small-3.11.5
      options: --privileged
    steps:
      - name: Install dev dependencies and setup git
        run: |
          apt update
          apt install -y build-essential cmake git libclang-dev pkg-config
          git config --global --add safe.directory $GITHUB_WORKSPACE

      - name: Checkout repository
        uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
        with:
          persist-credentials: false

      - name: Download sample GeoTIFF
        run: |
          curl --create-dir --remote-name --output-dir benches https://sentinel-cogs.s3.us-west-2.amazonaws.com/sentinel-s2-l2a-cogs/37/M/BV/2024/10/S2A_37MBV_20241029_0_L2A/TCI.tif
          ls -lh benches/

      - name: Setup rust toolchain, cache and cargo-codspeed binary
        uses: moonrepo/setup-rust@abb2d32350334249b178c401e5ec5836e0cd88d3 # v1.3.0
        with:
          channel: 1.91.0 # msrv
          cache: false
          cache-target: release
          bins: cargo-codspeed

      - name: Build the benchmark target(s)
        run: |
          cargo remove --dev gdal-src gdal-sys
          cargo codspeed build

      - name: Run the benchmarks
        uses: CodSpeedHQ/action@c381be0bfd20e844fb45594f6aa182ffcd94545c # v4.15.0
        with:
          mode: simulation
          run: cargo codspeed run

  python-benchmarks:
    name: "Run Python benchmarks"
    runs-on: ubuntu-24.04
    defaults:
      run:
        shell: bash -l {0}

    steps:
      # Checkout current git repository
      - name: Checkout
        uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
        with:
          persist-credentials: false

      # Setup Python interpreter
      - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
        with:
          python-version: "3.13"

      # Build binary distribution wheel
      - name: Build wheels
        uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1.51.0
        with:
          target: x86_64
          args: --release --out dist --find-interpreter
          sccache: "true"
          manylinux: auto

      # Install the package that we want to test
      - name: Install the package
        run: |
          set -e
          pip install cog3pio --no-index --no-deps --find-links dist --force-reinstall -vv
          pip install cog3pio --group benchmark
          python -m pip list

      # Run the benchmark tests
      - name: Run benchmarks
        uses: CodSpeedHQ/action@c381be0bfd20e844fb45594f6aa182ffcd94545c # v4.15.0
        with:
          mode: simulation
          run: python -m pytest --verbose --codspeed