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 committed Oct 22, 2022
1 parent b9241c0 commit e0b16e9
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion benches/chrono.rs
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 @@ -56,6 +56,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 @@ -109,6 +117,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 e0b16e9

Please sign in to comment.