MCPcopy Create free account
hub / github.com/SoftbearStudios/bitcode / benchmark_ns

Function benchmark_ns

src/benches.rs:195–211  ·  view source on GitHub ↗
(f: impl Fn())

Source from the content-addressed store, hash-verified

193 // }
194
195 fn benchmark_ns(f: impl Fn()) -> usize {
196 const WARMUP: usize = 2;
197 let start = Instant::now();
198 for _ in 0..WARMUP {
199 f();
200 }
201 let warmup_duration = start.elapsed();
202 let per_second = (WARMUP as f32 / warmup_duration.as_secs_f32()) as usize;
203 let samples: usize = (per_second / 32).max(1);
204 let mut duration = Duration::ZERO;
205 for _ in 0..samples {
206 let start = Instant::now();
207 f();
208 duration += start.elapsed();
209 }
210 duration.as_nanos() as usize / samples
211 }
212
213 let ser_time = benchmark_ns(|| {
214 black_box(ser(black_box(&data)));

Callers 1

comparison1Function · 0.85

Calls 1

fFunction · 0.85

Tested by

no test coverage detected