|
7 | 7 | //! selection. This is wall-clock timing — useful for local development feedback |
8 | 8 | //! and catching latency regressions across relay counts. |
9 | 9 | //! |
10 | | -//! Criterion runs each benchmark hundreds of times, applies statistical analysis, |
11 | | -//! and reports mean ± standard deviation. Results are saved to |
| 10 | +//! Criterion runs each benchmark hundreds of times, applies statistical |
| 11 | +//! analysis, and reports mean ± standard deviation. Results are saved to |
12 | 12 | //! `target/criterion/` as HTML reports (open `report/index.html`). |
13 | 13 | //! |
14 | 14 | //! # Running |
|
29 | 29 | //! |
30 | 30 | //! # What is NOT measured |
31 | 31 | //! |
32 | | -//! - PBS HTTP server overhead (we call `get_header()` directly, bypassing axum routing) |
33 | | -//! - Mock relay startup time (servers are started once in setup, before timing begins) |
34 | | -//! - `HeaderMap` allocation (created once in setup, cloned cheaply per iteration) |
| 32 | +//! - PBS HTTP server overhead (we call `get_header()` directly, bypassing axum |
| 33 | +//! routing) |
| 34 | +//! - Mock relay startup time (servers are started once in setup, before timing |
| 35 | +//! begins) |
| 36 | +//! - `HeaderMap` allocation (created once in setup, cloned cheaply per |
| 37 | +//! iteration) |
35 | 38 |
|
36 | 39 | use std::{path::PathBuf, sync::Arc, time::Duration}; |
37 | 40 |
|
@@ -73,7 +76,8 @@ fn bench_get_header(c: &mut Criterion) { |
73 | 76 | let rt = tokio::runtime::Runtime::new().expect("tokio runtime"); |
74 | 77 |
|
75 | 78 | // Start all mock relays once and build one PbsState per relay-count variant. |
76 | | - // All relays share the same MockRelayState (and therefore the same signing key). |
| 79 | + // All relays share the same MockRelayState (and therefore the same signing |
| 80 | + // key). |
77 | 81 | let (states, params) = rt.block_on(async { |
78 | 82 | let signer = random_secret(); |
79 | 83 | let pubkey = signer.public_key(); |
@@ -108,8 +112,9 @@ fn bench_get_header(c: &mut Criterion) { |
108 | 112 | (states, params) |
109 | 113 | }); |
110 | 114 |
|
111 | | - // Empty HeaderMap matches what the PBS route handler receives for requests without |
112 | | - // custom headers. Created once here to avoid measuring its allocation per iteration. |
| 115 | + // Empty HeaderMap matches what the PBS route handler receives for requests |
| 116 | + // without custom headers. Created once here to avoid measuring its |
| 117 | + // allocation per iteration. |
113 | 118 | let headers = HeaderMap::new(); |
114 | 119 |
|
115 | 120 | // A BenchmarkGroup groups related functions so Criterion produces a single |
@@ -142,7 +147,8 @@ fn bench_get_header(c: &mut Criterion) { |
142 | 147 | group.finish(); |
143 | 148 | } |
144 | 149 |
|
145 | | -// criterion_group! registers bench_get_header as a benchmark group named "benches". |
146 | | -// criterion_main! generates the main() entry point that Criterion uses to run them. |
| 150 | +// criterion_group! registers bench_get_header as a benchmark group named |
| 151 | +// "benches". criterion_main! generates the main() entry point that Criterion |
| 152 | +// uses to run them. |
147 | 153 | criterion_group!(benches, bench_get_header); |
148 | 154 | criterion_main!(benches); |
0 commit comments