bench: add criterion benchmarks for protocol, bandwidth, TCP RX scan, and EC-SRP5
Some checks failed
CI / test (push) Failing after 1m42s

Adds four Criterion.rs benchmark suites to measure hot-path performance
and demonstrate the impact of Sprints 1–3 optimizations:

- benches/protocol.rs    — Command & StatusMessage serialize/deserialize
- benches/bandwidth.rs   — BandwidthState atomics, budget, interval math
- benches/tcp_rx_scan.rs — memchr SIMD scan vs naive O(n) loop (55× faster
                           on 256KB buffers with status at end)
- benches/ecsrp5.rs      — WCurve::new() heavy math vs cached LazyLock
                           (~123,000× faster access)

Also adds BENCHMARKS.md with usage instructions and example results.

Visibility changes (bench-only):
- scan_status_message is now pub (was #[cfg(test)] only)
- WCurve and WCURVE are now pub in ecsrp5.rs

dev-dependencies: criterion + pprof (optional flamegraph support)
This commit is contained in:
Siavash Sameni
2026-04-30 21:01:38 +04:00
parent bba9b0512c
commit 3afbfb42cf
9 changed files with 969 additions and 18 deletions

View File

@@ -70,3 +70,25 @@ codegen-units = 1
inherits = "release"
opt-level = "z"
panic = "abort"
# --- Benchmarks ---
[dev-dependencies]
criterion = { version = "0.5", features = ["html_reports"] }
pprof = { version = "0.14", features = ["criterion", "flamegraph"] }
[[bench]]
name = "protocol"
harness = false
[[bench]]
name = "bandwidth"
harness = false
[[bench]]
name = "tcp_rx_scan"
harness = false
[[bench]]
name = "ecsrp5"
harness = false