From 74df2dadcd929431550d749e9f4aea2c7ccde242 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Tue, 17 Dec 2024 12:12:05 +0100 Subject: [PATCH] Add CI benchmarking --- .github/workflows/bench.yml | 57 +++++++++++++++++++++++++++++ zlib_benchmarks.json | 72 +++++++++++++++++++++++++++++++++++++ 2 files changed, 129 insertions(+) create mode 100644 .github/workflows/bench.yml create mode 100644 zlib_benchmarks.json diff --git a/.github/workflows/bench.yml b/.github/workflows/bench.yml new file mode 100644 index 0000000..b06809b --- /dev/null +++ b/.github/workflows/bench.yml @@ -0,0 +1,57 @@ +name: Benchmark + +permissions: + contents: read + +on: + push: + workflow_dispatch: + inputs: + ref: + description: "The commit or branch to benchmark" + required: true + type: string + merge_group: + branches: + - main + +# Make sure only a single benchmark job runs at a time for the main branch to prevent conflicts when +# pushing the benchmark data. +concurrency: + group: "benchmarking-${{inputs.ref}}" + cancel-in-progress: false + +jobs: + bench: + name: "Benchmark ${{ matrix.name }}" + runs-on: ${{ matrix.os }} + timeout-minutes: 30 + strategy: + matrix: + include: + - name: linux-x86 + os: [benchmark, X64] + target: "x86_64-unknown-linux-gnu" + - name: macos-arm64 + os: [benchmark, ARM64, macOS] + target: "aarch64-apple-darwin" + steps: + - name: Checkout sources + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + with: + persist-credentials: false + ref: "${{inputs.ref}}" + fetch-depth: 0 # ensure the base commit to compare against is available + - name: cargo build + run: | + . "$HOME/.cargo/env" + RUSTFLAGS="-Ctarget-cpu=native -Cllvm-args=-enable-dfa-jump-thread" cargo build --target ${{matrix.target}} -p test-libz-rs-sys --release --examples + cp target/${{matrix.target}}/release/examples/blogpost-compress . + cp target/${{matrix.target}}/release/examples/blogpost-uncompress . + - name: Benchmark + uses: trifectatechfoundation/benchmarker-action@main + with: + deploy-key: "${{ secrets.BENCH_DATA_DEPLOY_KEY }}" + bench-repo: "git@github.com:trifectatechfoundation/zlib-rs-bench.git" + metric-key: "${{ matrix.name }}" + benchmarks: "zlib_benchmarks.json" diff --git a/zlib_benchmarks.json b/zlib_benchmarks.json new file mode 100644 index 0000000..c9f26f7 --- /dev/null +++ b/zlib_benchmarks.json @@ -0,0 +1,72 @@ +{ + "blogpost-compress-rs": [ + "./blogpost-compress 0 rs silesia-small.tar", + "./blogpost-compress 1 rs silesia-small.tar", + "./blogpost-compress 2 rs silesia-small.tar", + "./blogpost-compress 3 rs silesia-small.tar", + "./blogpost-compress 4 rs silesia-small.tar", + "./blogpost-compress 5 rs silesia-small.tar", + "./blogpost-compress 6 rs silesia-small.tar", + "./blogpost-compress 7 rs silesia-small.tar", + "./blogpost-compress 8 rs silesia-small.tar", + "./blogpost-compress 9 rs silesia-small.tar" + ], + "blogpost-compress-ng": [ + "./blogpost-compress 0 ng silesia-small.tar", + "./blogpost-compress 1 ng silesia-small.tar", + "./blogpost-compress 2 ng silesia-small.tar", + "./blogpost-compress 3 ng silesia-small.tar", + "./blogpost-compress 4 ng silesia-small.tar", + "./blogpost-compress 5 ng silesia-small.tar", + "./blogpost-compress 6 ng silesia-small.tar", + "./blogpost-compress 7 ng silesia-small.tar", + "./blogpost-compress 8 ng silesia-small.tar", + "./blogpost-compress 9 ng silesia-small.tar" + ], + "blogpost-uncompress-rs": [ + "./blogpost-uncompress rs-chunked 4 silesia-small.tar", + "./blogpost-uncompress rs-chunked 5 silesia-small.tar", + "./blogpost-uncompress rs-chunked 6 silesia-small.tar", + "./blogpost-uncompress rs-chunked 7 silesia-small.tar", + "./blogpost-uncompress rs-chunked 8 silesia-small.tar", + "./blogpost-uncompress rs-chunked 9 silesia-small.tar", + "./blogpost-uncompress rs-chunked 10 silesia-small.tar", + "./blogpost-uncompress rs-chunked 11 silesia-small.tar", + "./blogpost-uncompress rs-chunked 12 silesia-small.tar", + "./blogpost-uncompress rs-chunked 13 silesia-small.tar", + "./blogpost-uncompress rs-chunked 14 silesia-small.tar", + "./blogpost-uncompress rs-chunked 15 silesia-small.tar", + "./blogpost-uncompress rs-chunked 16 silesia-small.tar", + "./blogpost-uncompress rs-chunked 17 silesia-small.tar", + "./blogpost-uncompress rs-chunked 18 silesia-small.tar", + "./blogpost-uncompress rs-chunked 19 silesia-small.tar", + "./blogpost-uncompress rs-chunked 20 silesia-small.tar", + "./blogpost-uncompress rs-chunked 21 silesia-small.tar", + "./blogpost-uncompress rs-chunked 22 silesia-small.tar", + "./blogpost-uncompress rs-chunked 23 silesia-small.tar", + "./blogpost-uncompress rs-chunked 24 silesia-small.tar" + ], + "blogpost-uncompress-ng": [ + "./blogpost-uncompress ng-chunked 4 silesia-small.tar", + "./blogpost-uncompress ng-chunked 5 silesia-small.tar", + "./blogpost-uncompress ng-chunked 6 silesia-small.tar", + "./blogpost-uncompress ng-chunked 7 silesia-small.tar", + "./blogpost-uncompress ng-chunked 8 silesia-small.tar", + "./blogpost-uncompress ng-chunked 9 silesia-small.tar", + "./blogpost-uncompress ng-chunked 10 silesia-small.tar", + "./blogpost-uncompress ng-chunked 11 silesia-small.tar", + "./blogpost-uncompress ng-chunked 12 silesia-small.tar", + "./blogpost-uncompress ng-chunked 13 silesia-small.tar", + "./blogpost-uncompress ng-chunked 14 silesia-small.tar", + "./blogpost-uncompress ng-chunked 15 silesia-small.tar", + "./blogpost-uncompress ng-chunked 16 silesia-small.tar", + "./blogpost-uncompress ng-chunked 17 silesia-small.tar", + "./blogpost-uncompress ng-chunked 18 silesia-small.tar", + "./blogpost-uncompress ng-chunked 19 silesia-small.tar", + "./blogpost-uncompress ng-chunked 20 silesia-small.tar", + "./blogpost-uncompress ng-chunked 21 silesia-small.tar", + "./blogpost-uncompress ng-chunked 22 silesia-small.tar", + "./blogpost-uncompress ng-chunked 23 silesia-small.tar", + "./blogpost-uncompress ng-chunked 24 silesia-small.tar" + ] +}