Skip to content

Commit 078340a

Browse files
committed
add cu bench recipe
1 parent 398227f commit 078340a

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

.github/workflows/main.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,23 @@ jobs:
130130
- name: Build Program
131131
run: make build-program
132132

133+
build_program:
134+
name: Test Program
135+
runs-on: ubuntu-latest
136+
steps:
137+
- name: Git Checkout
138+
uses: actions/checkout@v4
139+
140+
- name: Setup Environment
141+
uses: ./.github/actions/setup
142+
with:
143+
toolchain: build
144+
cargo-cache-key: cargo-program
145+
solana: true
146+
147+
- name: Build Program
148+
run: make build-program
149+
133150
test_program:
134151
name: Test Program
135152
runs-on: ubuntu-latest
@@ -147,6 +164,38 @@ jobs:
147164
- name: Test Program
148165
run: make test-program
149166

167+
bench_program_compute_units:
168+
name: Benchmark Program Compute Units
169+
runs-on: ubuntu-latest
170+
needs: build_program # Cargo Bench won't build the SBPF binary...
171+
steps:
172+
- name: Git Checkout
173+
uses: actions/checkout@v4
174+
175+
- name: Setup Environment
176+
uses: ./.github/actions/setup
177+
with:
178+
cargo-cache-key: cargo-program-benches
179+
cargo-cache-fallback-key: cargo-program
180+
solana: true
181+
182+
- name: Restore Program Builds
183+
uses: actions/cache/restore@v4
184+
with:
185+
path: ./**/*.so
186+
key: ${{ runner.os }}-builds-${{ github.sha }}
187+
188+
- name: Benchmark Compute Units
189+
run: make bench-program-compute-units
190+
191+
- name: Check Working Directory
192+
run: |
193+
if [ -n "$(git status --porcelain)" ]; then
194+
test -z "$(git status --porcelain)"
195+
echo "CU usage has changed. Please run `cargo bench` and commit the new results.";
196+
exit 1;
197+
fi
198+
150199
generate_clients:
151200
name: Check Client Generation
152201
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)