Skip to content

Commit 6cfca52

Browse files
committed
add cu bench recipe
1 parent 7307cd7 commit 6cfca52

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

.github/workflows/main.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,38 @@ jobs:
130130
- name: Test Program
131131
run: make test-program
132132

133+
bench_program_compute_units:
134+
name: Benchmark Program Compute Units
135+
runs-on: ubuntu-latest
136+
needs: build_program # Cargo Bench won't build the SBPF binary...
137+
steps:
138+
- name: Git Checkout
139+
uses: actions/checkout@v4
140+
141+
- name: Setup Environment
142+
uses: ./.github/actions/setup
143+
with:
144+
cargo-cache-key: cargo-program-benches
145+
cargo-cache-fallback-key: cargo-program
146+
solana: true
147+
148+
- name: Restore Program Builds
149+
uses: actions/cache/restore@v4
150+
with:
151+
path: ./**/*.so
152+
key: ${{ runner.os }}-builds-${{ github.sha }}
153+
154+
- name: Benchmark Compute Units
155+
run: make bench-program-compute-units
156+
157+
- name: Check Working Directory
158+
run: |
159+
if [ -n "$(git status --porcelain)" ]; then
160+
test -z "$(git status --porcelain)"
161+
echo "CU usage has changed. Please run `cargo bench` and commit the new results.";
162+
exit 1;
163+
fi
164+
133165
generate_clients:
134166
name: Check Client Generation
135167
runs-on: ubuntu-latest

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ test-%:
3232
build-program:
3333
cargo test-sbf --manifest-path program/Cargo.toml --features bpf-entrypoint
3434

35+
bench-program-compute-units:
36+
cargo bench --manifest-path program/Cargo.toml
37+
3538
format-js:
3639
cd ./clients/js && pnpm install && pnpm format
3740

0 commit comments

Comments
 (0)