Skip to content

Commit 043beed

Browse files
committed
add codec benches
1 parent 78585d7 commit 043beed

9 files changed

Lines changed: 2029 additions & 0 deletions

File tree

sv2/codec-sv2/BENCHES.md

Lines changed: 775 additions & 0 deletions
Large diffs are not rendered by default.

sv2/codec-sv2/Cargo.toml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ tracing = { workspace = true, optional = true }
2121

2222
[dev-dependencies]
2323
key-utils = { workspace = true }
24+
criterion = { version = "0.3.0", features = ["html_reports"] }
25+
rayon-core = "=1.12.1"
2426

2527
[features]
2628
default = ["std"]
@@ -30,3 +32,24 @@ tracing = ["dep:tracing"]
3032

3133
[package.metadata.docs.rs]
3234
features = ["with_buffer_pool", "noise_sv2", "std"]
35+
36+
37+
[[bench]]
38+
name = "encoder"
39+
harness = false
40+
41+
[[bench]]
42+
name = "decoder"
43+
harness = false
44+
45+
[[bench]]
46+
name = "noise_roundtrip"
47+
harness = false
48+
49+
[[bench]]
50+
name = "serialization"
51+
harness = false
52+
53+
[[bench]]
54+
name = "buffer_exhaustion"
55+
harness = false

sv2/codec-sv2/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,24 @@ This crate provides two examples demonstrating how to encode and decode Sv2 fram
4646
Encode and decode Sv2 frames with Noise protocol encryption, detailing the entire encryption
4747
handshake and transport phase and serialization and transmission process for encrypted
4848
communications.
49+
50+
## Benchmarks
51+
52+
Performance benchmarks are provided for all major code paths: plain encoding/decoding,
53+
Noise protocol encryption, serialization, and buffer pool exhaustion behavior.
54+
55+
See **[BENCHES.md](BENCHES.md)** for the full benchmark suite documentation, including:
56+
- How to run each suite and which feature flags are needed
57+
- Descriptions of every benchmark target
58+
- Measured results with and without `with_buffer_pool` / `noise_sv2`
59+
- Analysis of buffer pool exhaustion thresholds and Alloc-mode overhead
60+
61+
Quick start:
62+
63+
```bash
64+
# Run all benchmarks with all features
65+
cargo bench --all-features
66+
67+
# Run only the pool exhaustion benchmarks
68+
cargo bench --bench buffer_exhaustion
69+
```

0 commit comments

Comments
 (0)