Skip to content

Commit

Permalink
Add benchmark for DateTime::with_*
Browse files Browse the repository at this point in the history
  • Loading branch information
pitdicker committed Sep 23, 2023
1 parent 41e34ad commit 45f1a4d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions bench/benches/chrono.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,13 @@ fn bench_naivedate_add_signed(c: &mut Criterion) {
});
}

fn bench_datetime_with(c: &mut Criterion) {
let dt = FixedOffset::east_opt(3600).unwrap().with_ymd_and_hms(2023, 9, 23, 7, 36, 0).unwrap();
c.bench_function("bench_datetime_with", |b| {
b.iter(|| black_box(black_box(dt).with_hour(12)).unwrap())
});
}

criterion_group!(
benches,
bench_datetime_parse_from_rfc2822,
Expand All @@ -220,6 +227,7 @@ criterion_group!(
bench_format_with_items,
bench_format_manual,
bench_naivedate_add_signed,
bench_datetime_with,
);

#[cfg(feature = "unstable-locales")]
Expand Down

0 comments on commit 45f1a4d

Please sign in to comment.