-
Notifications
You must be signed in to change notification settings - Fork 16
76 lines (71 loc) · 2.62 KB
/
bench.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
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: 2
- name: cargo build
run: |
. "$HOME/.cargo/env"
cargo build --target ${{matrix.target}} -p test-libz-rs-sys --release --examples
cd benchmarker && cargo build --release
- name: Fetch previous benchmark results
run: |
mkdir -p ~/.ssh
echo "${{ secrets.BENCH_DATA_DEPLOY_KEY }}" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
chmod 700 ~/.ssh
git clone --depth 1 [email protected]:trifectatechfoundation/zlib-rs-bench.git
- name: Benchmark
run: |
cp target/${{matrix.target}}/release/examples/blogpost-compress .
benchmarker/target/release/benchmarker zlib_benchmarks.json zlib-rs-bench/metrics-${{matrix.name}}.json > bench_results.json
- name: Upload benchmark results to artifacts
uses: actions/upload-artifact@v4
with:
name: "benchmark-results-${{matrix.name}}"
path: bench_results.json
- name: Upload benchmark results to bench repo
if: github.event_name == 'push'
run: |
cd zlib-rs-bench
git pull # ensure we have the latest state when another job pushed changes while benchmarking
cat ../bench_results.json >> metrics-${{matrix.name}}.json
git add .
git -c user.name="Perf bot" -c [email protected] commit --message 📈
# git pull --rebase in case of a race condition with another job
git push origin main || (git -c user.name="Perf bot" -c [email protected] pull --rebase && git push origin main)