Debian Codegraph @

debian/missing-sources/time/benchmarks/rand08.rs

raw
1 use criterion::Bencher;
2 use rand08::rngs::mock::StepRng;
3 use rand08::Rng;
4 use time::{Date, Duration, Month, OffsetDateTime, PrimitiveDateTime, Time, UtcOffset, Weekday};
5
6 macro_rules! bench_rand {
7 ($($name:ident : $type:ty),* $(,)?) => {
8 setup_benchmark! {
9 "Random",
10 $(fn $name(ben: &mut Bencher<'_>) {
11 iter_batched_ref!(
12 ben,
13 || StepRng::new(0, 1),
14 [|rng| rng.r#gen::<$type>()]
15 );
16 })*
17 }
18 }
19 }
20
21 bench_rand![
22 time: Time,
23 date: Date,
24 utc_offset: UtcOffset,
25 primitive_date_time: PrimitiveDateTime,
26 offset_date_time: OffsetDateTime,
27 duration: Duration,
28 weekday: Weekday,
29 month: Month,
30 ];