Skip to content

Commit 2b4dc78

Browse files
bjorn3folkertdev
andcommitted
Add CI benchmarking
Co-Authored-By: Folkert de Vries <folkert@folkertdev.nl>
1 parent 6f8c517 commit 2b4dc78

File tree

2 files changed

+197
-0
lines changed

2 files changed

+197
-0
lines changed

.github/workflows/bench.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Benchmark
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
push:
8+
workflow_dispatch:
9+
inputs:
10+
ref:
11+
description: "The commit or branch to benchmark"
12+
required: true
13+
type: string
14+
merge_group:
15+
branches:
16+
- main
17+
18+
# Make sure only a single benchmark job runs at a time for the main branch to prevent conflicts when
19+
# pushing the benchmark data.
20+
concurrency:
21+
group: "benchmarking-${{inputs.ref}}"
22+
cancel-in-progress: false
23+
24+
jobs:
25+
bench:
26+
name: "Benchmark ${{ matrix.name }}"
27+
runs-on: ${{ matrix.os }}
28+
timeout-minutes: 30
29+
strategy:
30+
matrix:
31+
include:
32+
- name: linux-x86
33+
os: [benchmark, X64]
34+
target: "x86_64-unknown-linux-gnu"
35+
- name: macos-arm64
36+
os: [benchmark, ARM64, macOS]
37+
target: "aarch64-apple-darwin"
38+
steps:
39+
- name: Checkout sources
40+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
41+
with:
42+
persist-credentials: false
43+
ref: "${{inputs.ref}}"
44+
fetch-depth: 0 # ensure the base commit to compare against is available
45+
- name: cargo build
46+
run: |
47+
. "$HOME/.cargo/env"
48+
RUSTFLAGS="-Cllvm-args=-enable-dfa-jump-thread" cargo build --target ${{matrix.target}} -p test-libz-rs-sys --release --examples
49+
cp target/${{matrix.target}}/release/examples/blogpost-compress .
50+
cp target/${{matrix.target}}/release/examples/blogpost-uncompress .
51+
- name: Benchmark
52+
uses: trifectatechfoundation/benchmarker-action@main
53+
with:
54+
deploy-key: "${{ secrets.BENCH_DATA_DEPLOY_KEY }}"
55+
bench-repo: "git@github.com:trifectatechfoundation/zlib-rs-bench.git"
56+
metric-key: "${{ matrix.name }}"
57+
benchmarks: "zlib_benchmarks.json"

zlib_benchmarks.json

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
{
2+
"commands": {
3+
"blogpost-compress-rs": [
4+
"./blogpost-compress 0 rs silesia-small.tar",
5+
"./blogpost-compress 1 rs silesia-small.tar",
6+
"./blogpost-compress 2 rs silesia-small.tar",
7+
"./blogpost-compress 3 rs silesia-small.tar",
8+
"./blogpost-compress 4 rs silesia-small.tar",
9+
"./blogpost-compress 5 rs silesia-small.tar",
10+
"./blogpost-compress 6 rs silesia-small.tar",
11+
"./blogpost-compress 7 rs silesia-small.tar",
12+
"./blogpost-compress 8 rs silesia-small.tar",
13+
"./blogpost-compress 9 rs silesia-small.tar"
14+
],
15+
"blogpost-compress-ng": [
16+
"./blogpost-compress 0 ng silesia-small.tar",
17+
"./blogpost-compress 1 ng silesia-small.tar",
18+
"./blogpost-compress 2 ng silesia-small.tar",
19+
"./blogpost-compress 3 ng silesia-small.tar",
20+
"./blogpost-compress 4 ng silesia-small.tar",
21+
"./blogpost-compress 5 ng silesia-small.tar",
22+
"./blogpost-compress 6 ng silesia-small.tar",
23+
"./blogpost-compress 7 ng silesia-small.tar",
24+
"./blogpost-compress 8 ng silesia-small.tar",
25+
"./blogpost-compress 9 ng silesia-small.tar"
26+
],
27+
"blogpost-uncompress-rs": [
28+
"./blogpost-uncompress rs-chunked 4 silesia-small.tar",
29+
"./blogpost-uncompress rs-chunked 5 silesia-small.tar",
30+
"./blogpost-uncompress rs-chunked 6 silesia-small.tar",
31+
"./blogpost-uncompress rs-chunked 7 silesia-small.tar",
32+
"./blogpost-uncompress rs-chunked 8 silesia-small.tar",
33+
"./blogpost-uncompress rs-chunked 9 silesia-small.tar",
34+
"./blogpost-uncompress rs-chunked 10 silesia-small.tar",
35+
"./blogpost-uncompress rs-chunked 11 silesia-small.tar",
36+
"./blogpost-uncompress rs-chunked 12 silesia-small.tar",
37+
"./blogpost-uncompress rs-chunked 13 silesia-small.tar",
38+
"./blogpost-uncompress rs-chunked 14 silesia-small.tar",
39+
"./blogpost-uncompress rs-chunked 15 silesia-small.tar",
40+
"./blogpost-uncompress rs-chunked 16 silesia-small.tar",
41+
"./blogpost-uncompress rs-chunked 17 silesia-small.tar",
42+
"./blogpost-uncompress rs-chunked 18 silesia-small.tar",
43+
"./blogpost-uncompress rs-chunked 19 silesia-small.tar",
44+
"./blogpost-uncompress rs-chunked 20 silesia-small.tar",
45+
"./blogpost-uncompress rs-chunked 21 silesia-small.tar",
46+
"./blogpost-uncompress rs-chunked 22 silesia-small.tar",
47+
"./blogpost-uncompress rs-chunked 23 silesia-small.tar",
48+
"./blogpost-uncompress rs-chunked 24 silesia-small.tar"
49+
],
50+
"blogpost-uncompress-ng": [
51+
"./blogpost-uncompress ng-chunked 4 silesia-small.tar",
52+
"./blogpost-uncompress ng-chunked 5 silesia-small.tar",
53+
"./blogpost-uncompress ng-chunked 6 silesia-small.tar",
54+
"./blogpost-uncompress ng-chunked 7 silesia-small.tar",
55+
"./blogpost-uncompress ng-chunked 8 silesia-small.tar",
56+
"./blogpost-uncompress ng-chunked 9 silesia-small.tar",
57+
"./blogpost-uncompress ng-chunked 10 silesia-small.tar",
58+
"./blogpost-uncompress ng-chunked 11 silesia-small.tar",
59+
"./blogpost-uncompress ng-chunked 12 silesia-small.tar",
60+
"./blogpost-uncompress ng-chunked 13 silesia-small.tar",
61+
"./blogpost-uncompress ng-chunked 14 silesia-small.tar",
62+
"./blogpost-uncompress ng-chunked 15 silesia-small.tar",
63+
"./blogpost-uncompress ng-chunked 16 silesia-small.tar",
64+
"./blogpost-uncompress ng-chunked 17 silesia-small.tar",
65+
"./blogpost-uncompress ng-chunked 18 silesia-small.tar",
66+
"./blogpost-uncompress ng-chunked 19 silesia-small.tar",
67+
"./blogpost-uncompress ng-chunked 20 silesia-small.tar",
68+
"./blogpost-uncompress ng-chunked 21 silesia-small.tar",
69+
"./blogpost-uncompress ng-chunked 22 silesia-small.tar",
70+
"./blogpost-uncompress ng-chunked 23 silesia-small.tar",
71+
"./blogpost-uncompress ng-chunked 24 silesia-small.tar"
72+
]
73+
},
74+
"render-versus-self": {
75+
"compression (ng vs rs)": {
76+
"level 0": { "measure": "cycles", "before": { "command": "blogpost-compress-ng", "index": 0 }, "after": { "command": "blogpost-compress-rs", "index": 0 } },
77+
"level 1": { "measure": "cycles", "before": { "command": "blogpost-compress-ng", "index": 1 }, "after": { "command": "blogpost-compress-rs", "index": 1 } },
78+
"level 2": { "measure": "cycles", "before": { "command": "blogpost-compress-ng", "index": 2 }, "after": { "command": "blogpost-compress-rs", "index": 2 } },
79+
"level 3": { "measure": "cycles", "before": { "command": "blogpost-compress-ng", "index": 3 }, "after": { "command": "blogpost-compress-rs", "index": 3 } },
80+
"level 4": { "measure": "cycles", "before": { "command": "blogpost-compress-ng", "index": 4 }, "after": { "command": "blogpost-compress-rs", "index": 4 } },
81+
"level 5": { "measure": "cycles", "before": { "command": "blogpost-compress-ng", "index": 5 }, "after": { "command": "blogpost-compress-rs", "index": 5 } },
82+
"level 6": { "measure": "cycles", "before": { "command": "blogpost-compress-ng", "index": 6 }, "after": { "command": "blogpost-compress-rs", "index": 6 } },
83+
"level 7": { "measure": "cycles", "before": { "command": "blogpost-compress-ng", "index": 7 }, "after": { "command": "blogpost-compress-rs", "index": 7 } },
84+
"level 8": { "measure": "cycles", "before": { "command": "blogpost-compress-ng", "index": 8 }, "after": { "command": "blogpost-compress-rs", "index": 8 } },
85+
"level 9": { "measure": "cycles", "before": { "command": "blogpost-compress-ng", "index": 9 }, "after": { "command": "blogpost-compress-rs", "index": 9 } }
86+
},
87+
"decompression (ng vs rs)": {
88+
"chunk size 4": { "measure": "cycles", "before": { "command": "blogpost-uncompress-ng", "index": 0 }, "after": { "command": "blogpost-uncompress-rs", "index": 0 } },
89+
"chunk size 5": { "measure": "cycles", "before": { "command": "blogpost-uncompress-ng", "index": 1 }, "after": { "command": "blogpost-uncompress-rs", "index": 1 } },
90+
"chunk size 6": { "measure": "cycles", "before": { "command": "blogpost-uncompress-ng", "index": 2 }, "after": { "command": "blogpost-uncompress-rs", "index": 2 } },
91+
"chunk size 7": { "measure": "cycles", "before": { "command": "blogpost-uncompress-ng", "index": 3 }, "after": { "command": "blogpost-uncompress-rs", "index": 3 } },
92+
"chunk size 8": { "measure": "cycles", "before": { "command": "blogpost-uncompress-ng", "index": 4 }, "after": { "command": "blogpost-uncompress-rs", "index": 4 } },
93+
"chunk size 9": { "measure": "cycles", "before": { "command": "blogpost-uncompress-ng", "index": 5 }, "after": { "command": "blogpost-uncompress-rs", "index": 5 } },
94+
"chunk size 10": { "measure": "cycles", "before": { "command": "blogpost-uncompress-ng", "index": 6 }, "after": { "command": "blogpost-uncompress-rs", "index": 6 } },
95+
"chunk size 11": { "measure": "cycles", "before": { "command": "blogpost-uncompress-ng", "index": 7 }, "after": { "command": "blogpost-uncompress-rs", "index": 7 } },
96+
"chunk size 12": { "measure": "cycles", "before": { "command": "blogpost-uncompress-ng", "index": 8 }, "after": { "command": "blogpost-uncompress-rs", "index": 8 } },
97+
"chunk size 13": { "measure": "cycles", "before": { "command": "blogpost-uncompress-ng", "index": 9 }, "after": { "command": "blogpost-uncompress-rs", "index": 9 } },
98+
"chunk size 14": { "measure": "cycles", "before": { "command": "blogpost-uncompress-ng", "index": 10 }, "after": { "command": "blogpost-uncompress-rs", "index": 10 } },
99+
"chunk size 15": { "measure": "cycles", "before": { "command": "blogpost-uncompress-ng", "index": 11 }, "after": { "command": "blogpost-uncompress-rs", "index": 11 } },
100+
"chunk size 16": { "measure": "cycles", "before": { "command": "blogpost-uncompress-ng", "index": 12 }, "after": { "command": "blogpost-uncompress-rs", "index": 12 } }
101+
}
102+
},
103+
"render-versus-other": {
104+
"compression (rs, other versus self)": {
105+
"measure": "cycles",
106+
"command": "blogpost-compress-rs",
107+
"rows": {
108+
"level 0": 0,
109+
"level 1": 1,
110+
"level 2": 2,
111+
"level 3": 3,
112+
"level 4": 4,
113+
"level 5": 5,
114+
"level 6": 6,
115+
"level 7": 7,
116+
"level 8": 8,
117+
"level 9": 9
118+
}
119+
},
120+
"decompression (rs, other versus self)": {
121+
"measure": "cycles",
122+
"command": "blogpost-uncompress-rs",
123+
"rows": {
124+
"chunk size 4": 0,
125+
"chunk size 5": 1,
126+
"chunk size 6": 2,
127+
"chunk size 7": 3,
128+
"chunk size 8": 4,
129+
"chunk size 9": 5,
130+
"chunk size 10": 6,
131+
"chunk size 11": 7,
132+
"chunk size 12": 8,
133+
"chunk size 13": 9,
134+
"chunk size 14": 10,
135+
"chunk size 15": 11,
136+
"chunk size 16": 12
137+
}
138+
}
139+
}
140+
}

0 commit comments

Comments
 (0)