| 1 |
use criterion::Bencher; |
| 2 |
use rand08::Rng; |
| 3 |
use rand08::rngs::mock::StepRng; |
| 4 |
use time::{Date, Month, OffsetDateTime, PlainDateTime, SignedDuration, 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 |
plain_date_time: PlainDateTime, |
| 26 |
offset_date_time: OffsetDateTime, |
| 27 |
duration: SignedDuration, |
| 28 |
weekday: Weekday, |
| 29 |
month: Month, |
| 30 |
]; |