Skip to content

Commit 9dc5609

Browse files
authored
Add criterion benchmarks and live throughput bench script (#3)
* Add criterion benchmarks and live throughput bench script - Add lib.rs to expose modules for external benchmarking - Criterion benchmarks for crypto (md4, sha256, hmac_md5, hmac_sha256, hex_encode) and protocol (header encode/decode, frame_packet, build_request, decode responses, parse_directory_entries, NtStatus) - Live throughput script (scripts/bench-live.sh): single-file write/read at 1MB-1GB, multi-file writes, ~10GB total data volume - Makefile targets: make bench, make bench-live * Add pre-PR checklist to CLAUDE.md, fix clippy warnings - Document fmt/clippy/rustdoc/test checks to run before creating PRs - Add Default impls for MultipartStore and XmlWriter (clippy::new_without_default) * Address PR #3 review comments - Add --locked to bench and bench-live build commands - Use /dev/zero instead of /dev/urandom to avoid RNG bottleneck - Remove unused human_size function - Fix aggregate totals and use MiB units consistently - Update script header with actual dependencies - Pre-allocate buffers outside b.iter in protocol benchmarks - Use typed enums (DesiredAccess, ShareAccess, etc.) instead of raw constants * Run criterion benchmarks in CI * Address PR #3 review comments (round 2) - Wrap all benchmark return values in black_box to prevent elision - CI: compile-check benchmarks (--no-run) instead of running them
1 parent e989c6c commit 9dc5609

12 files changed

Lines changed: 953 additions & 8 deletions

File tree

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ jobs:
8080
SPICEIO_REGION: ${{ vars.SPICEIO_REGION || 'us-west-1' }}
8181
run: ./scripts/test-sccache.sh
8282

83+
- name: Compile benchmarks
84+
run: cargo bench --locked --no-run
85+
8386
- name: Build release artifact
8487
run: cargo build --release --locked --bin spiceio
8588

CLAUDE.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,27 @@ make release # optimized release build
2121
make lint # fmt-check + check + strict clippy + rustdoc warnings
2222
make test # sccache integration test (requires SPICEIO_SMB_USER/PASS)
2323
make fmt # auto-format
24+
make bench # criterion benchmarks (crypto + protocol)
25+
make bench-live # live throughput benchmarks against NAS
2426
make clean # cargo clean
2527
```
2628

29+
## Pre-PR checklist
30+
31+
Always run these before creating a PR — they mirror what CI checks:
32+
33+
```bash
34+
cargo fmt --all # auto-format first
35+
cargo fmt --all --check # verify no formatting diff remains
36+
cargo clippy --locked --all-targets --all-features -- -D warnings -D clippy::all -D clippy::cargo -A clippy::cargo-common-metadata
37+
RUSTDOCFLAGS="-D warnings" cargo doc --locked --workspace --no-deps --document-private-items
38+
cargo test --locked # unit tests must pass
39+
```
40+
41+
Or simply: `make lint && cargo test --locked`
42+
43+
The CI also runs `./scripts/test-sccache.sh` (sccache integration test) when SMB credentials are available.
44+
2745
The binary requires these environment variables:
2846
- `SPICEIO_SMB_SERVER` (required) — SMB server hostname or IP
2947
- `SPICEIO_SMB_USER` (required) — SMB username

0 commit comments

Comments
 (0)