bench: add criterion benchmarks for protocol, bandwidth, TCP RX scan, and EC-SRP5
Some checks failed
CI / test (push) Failing after 1m42s
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:
19
benches/ecsrp5.rs
Normal file
19
benches/ecsrp5.rs
Normal file
@@ -0,0 +1,19 @@
|
||||
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
||||
use btest_rs::ecsrp5::{WCurve, WCURVE};
|
||||
|
||||
fn bench_wcurve_new(c: &mut Criterion) {
|
||||
c.bench_function("wcurve_new_uncached", |b| {
|
||||
b.iter(|| black_box(WCurve::new()))
|
||||
});
|
||||
}
|
||||
|
||||
fn bench_wcurve_cached(c: &mut Criterion) {
|
||||
// Force initialization before benchmarking
|
||||
let _ = &*WCURVE;
|
||||
c.bench_function("wcurve_cached_access", |b| {
|
||||
b.iter(|| black_box(&*WCURVE))
|
||||
});
|
||||
}
|
||||
|
||||
criterion_group!(ecsrp5_benches, bench_wcurve_new, bench_wcurve_cached);
|
||||
criterion_main!(ecsrp5_benches);
|
||||
Reference in New Issue
Block a user