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