mirror of
https://github.com/chronotope/chrono.git
synced 2025-09-26 20:40:51 +00:00
Add benchmark
This commit is contained in:
parent
084b021576
commit
d68f151b81
@ -6,7 +6,7 @@ use chrono::format::StrftimeItems;
|
||||
use chrono::prelude::*;
|
||||
#[cfg(feature = "unstable-locales")]
|
||||
use chrono::Locale;
|
||||
use chrono::{DateTime, FixedOffset, Local, Utc, __BenchYearFlags};
|
||||
use chrono::{DateTime, Duration, FixedOffset, Local, Utc, __BenchYearFlags};
|
||||
|
||||
fn bench_datetime_parse_from_rfc2822(c: &mut Criterion) {
|
||||
c.bench_function("bench_datetime_parse_from_rfc2822", |b| {
|
||||
@ -195,6 +195,15 @@ fn bench_format_manual(c: &mut Criterion) {
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
fn bench_naivedate_add_signed(c: &mut Criterion) {
|
||||
let date = NaiveDate::from_ymd_opt(2023, 7, 29).unwrap();
|
||||
let extra = Duration::days(25);
|
||||
c.bench_function("bench_naivedate_add_signed", |b| {
|
||||
b.iter(|| black_box(date).checked_add_signed(extra).unwrap())
|
||||
});
|
||||
}
|
||||
|
||||
criterion_group!(
|
||||
benches,
|
||||
bench_datetime_parse_from_rfc2822,
|
||||
@ -210,6 +219,7 @@ criterion_group!(
|
||||
bench_format,
|
||||
bench_format_with_items,
|
||||
bench_format_manual,
|
||||
bench_naivedate_add_signed,
|
||||
);
|
||||
|
||||
#[cfg(feature = "unstable-locales")]
|
||||
|
Loading…
x
Reference in New Issue
Block a user