Skip to content

Commit 0194e29

Browse files
committed
add CU benching to CI
1 parent 94fed8a commit 0194e29

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed

.github/workflows/main.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,29 @@ jobs:
109109
- name: Test Programs
110110
run: pnpm programs:test
111111

112+
bench_program_compute_units:
113+
name: Benchmark Program Compute Units
114+
runs-on: ubuntu-latest
115+
needs: format_and_lint_programs
116+
steps:
117+
- name: Git Checkout
118+
uses: actions/checkout@v4
119+
120+
- name: Setup Environment
121+
uses: ./.github/actions/setup
122+
with:
123+
cargo-cache-key: cargo-program-benches
124+
cargo-cache-fallback-key: cargo-programs
125+
solana: true
126+
127+
- name: Benchmark Compute Units
128+
run: pnpm programs:bench
129+
130+
- name: Check Working Directory
131+
run: |
132+
git status --porcelain
133+
test -z "$(git status --porcelain)"
134+
112135
## SKIP: IDL is hand-cranked here for now.
113136
##
114137
# generate_idls:

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"scripts": {
44
"programs:build": "zx ./scripts/program/build.mjs",
55
"programs:test": "zx ./scripts/program/test.mjs",
6+
"programs:bench": "zx ./scripts/program/bench.mjs",
67
"programs:clean": "zx ./scripts/program/clean.mjs",
78
"programs:format": "zx ./scripts/program/format.mjs",
89
"programs:lint": "zx ./scripts/program/lint.mjs",

scripts/program/bench.mjs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env zx
2+
import 'zx/globals';
3+
import {
4+
cliArguments,
5+
getProgramFolders,
6+
workingDirectory,
7+
} from '../utils.mjs';
8+
9+
// Save external programs binaries to the output directory.
10+
import './dump.mjs';
11+
12+
// Configure additional arguments here, e.g.:
13+
// ['--arg1', '--arg2', ...cliArguments()]
14+
const benchArgs = [
15+
'--features',
16+
'bpf-entrypoint',
17+
...cliArguments(),
18+
];
19+
20+
const hasSolfmt = await which('solfmt', { nothrow: true });
21+
22+
// Test the programs.
23+
await Promise.all(
24+
getProgramFolders().map(async (folder) => {
25+
const manifestPath = path.join(workingDirectory, folder, 'Cargo.toml');
26+
27+
if (hasSolfmt) {
28+
await $`RUST_LOG=error cargo bench --manifest-path ${manifestPath} ${benchArgs} 2>&1 | solfmt`;
29+
} else {
30+
await $`RUST_LOG=error cargo bench --manifest-path ${manifestPath} ${benchArgs}`;
31+
}
32+
})
33+
);

0 commit comments

Comments
 (0)