Skip to content

Commit b33ded9

Browse files
alextrnnnok-nick
andauthored
feat: Add benchmarking (#1311)
* feat: Add benchmarking into ci * Update ci.yml * fix: Conditionally run benchmarking * Update ci.yml * Update ci.yml * test: Try to move action to separate file * Update codspeed.yml * Update codspeed.yml * Update codspeed.yml * Update codspeed.yml * Update codspeed.yml * feat: Add more formats for signing * feat: Add reading benchmarks * feat: Cool new feature * fix: Revert changes * chore: Remove unused imports * chore: Error * fix: Remove the extra tests * ci: run codspeed only on c2pa with no default features and rust_native_crypto * ci: use consistent install workflow for benchmarks * ci: use cargo-binstall@main * ci: run benchmarks on all 'safe to test' * ci: disable default features on WASM/WASI for criterion * build: simplify conditional dev dependency target --------- Co-authored-by: ok-nick <[email protected]>
1 parent 10202e5 commit b33ded9

23 files changed

+4538
-4
lines changed

.github/workflows/ci.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,42 @@ jobs:
311311
env:
312312
WASM_BINDGEN_TEST_TIMEOUT: 60
313313

314+
benchmarks:
315+
name: Run benchmarks on signing and reading
316+
if: |
317+
github.event_name != 'pull_request' ||
318+
github.event.pull_request.author_association == 'COLLABORATOR' ||
319+
github.event.pull_request.author_association == 'MEMBER' ||
320+
github.event.pull_request.user.login == 'dependabot[bot]' ||
321+
contains(github.event.pull_request.labels.*.name, 'safe to test')
322+
323+
runs-on: ubuntu-latest
324+
325+
steps:
326+
- name: Checkout repository
327+
uses: actions/checkout@v4
328+
329+
- name: Install Rust toolchain
330+
uses: dtolnay/rust-toolchain@stable
331+
332+
- name: Install cargo-binstall
333+
uses: cargo-bins/cargo-binstall@main
334+
335+
- name: Install cargo-codspeed
336+
run: cargo binstall --no-confirm cargo-codspeed
337+
338+
- name: Cache Rust dependencies
339+
uses: Swatinem/rust-cache@v2
340+
341+
- name: Build the benchmark target(s)
342+
run: cargo codspeed build -p c2pa --no-default-features --features rust_native_crypto
343+
344+
- name: Run the benchmarks
345+
uses: CodSpeedHQ/action@v3
346+
with:
347+
run: cargo codspeed run
348+
token: ${{ secrets.CODSPEED_TOKEN }}
349+
314350
tests-wasi:
315351
name: Unit tests (WASI)
316352
needs: get-features

Cargo.lock

Lines changed: 186 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/Cargo.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,21 @@ wasm-bindgen-test = "0.3.45"
288288
[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
289289
httpmock = "0.7.0"
290290
tokio = { version = "1.44.2", features = ["full"] }
291+
criterion = { package = "codspeed-criterion-compat", version = "3.0.5" }
292+
#
293+
# WASM/WASI doesn't support default criterion features.
294+
# https://github.com/bheisler/criterion.rs/blob/4c19e913b84e6a7e4a8470cb0f766796886ed891/book/src/user_guide/wasi.md
295+
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
296+
criterion = { package = "codspeed-criterion-compat", version = "3.0.5", default-features = false }
297+
298+
[[bench]]
299+
name = "sign"
300+
harness = false
301+
302+
[[bench]]
303+
name = "read"
304+
harness = false
305+
291306

292307
[package.metadata.cargo-udeps.ignore]
293308
normal = ["windows-core"]
114 KB
Loading
204 KB
Loading
114 KB
Binary file not shown.
113 KB
Binary file not shown.

sdk/benches/fixtures/100kb-signed.pdf

Whitespace-only changes.
215 KB
Loading

sdk/benches/fixtures/100kb-signed.svg

Lines changed: 2003 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)