Skip to content

Commit

Permalink
add bench for Local::now()
Browse files Browse the repository at this point in the history
  • Loading branch information
esheppa authored and djc committed Nov 11, 2022
1 parent 22b4d32 commit 8bc4139
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion benches/chrono.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion};

use chrono::prelude::*;
use chrono::{DateTime, FixedOffset, Utc, __BenchYearFlags};
use chrono::{DateTime, FixedOffset, Local, Utc, __BenchYearFlags};

fn bench_datetime_parse_from_rfc2822(c: &mut Criterion) {
c.bench_function("bench_datetime_parse_from_rfc2822", |b| {
Expand Down Expand Up @@ -70,6 +70,14 @@ fn bench_year_flags_from_year(c: &mut Criterion) {
});
}

fn bench_get_local_time(c: &mut Criterion) {
c.bench_function("bench_get_local_time", |b| {
b.iter(|| {
let _ = Local::now();
})
});
}

/// Returns the number of multiples of `div` in the range `start..end`.
///
/// If the range `start..end` is back-to-front, i.e. `start` is greater than `end`, the
Expand Down Expand Up @@ -123,6 +131,7 @@ criterion_group!(
bench_datetime_to_rfc3339,
bench_year_flags_from_year,
bench_num_days_from_ce,
bench_get_local_time,
);

criterion_main!(benches);

0 comments on commit 8bc4139

Please sign in to comment.