mirror of
https://github.com/chronotope/chrono.git
synced 2025-09-28 05:21:39 +00:00
add bench for Local::now()
This commit is contained in:
parent
22b4d32498
commit
8bc413936f
@ -4,7 +4,7 @@
|
|||||||
use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion};
|
use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion};
|
||||||
|
|
||||||
use chrono::prelude::*;
|
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) {
|
fn bench_datetime_parse_from_rfc2822(c: &mut Criterion) {
|
||||||
c.bench_function("bench_datetime_parse_from_rfc2822", |b| {
|
c.bench_function("bench_datetime_parse_from_rfc2822", |b| {
|
||||||
@ -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`.
|
/// 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
|
/// If the range `start..end` is back-to-front, i.e. `start` is greater than `end`, the
|
||||||
@ -123,6 +131,7 @@ criterion_group!(
|
|||||||
bench_datetime_to_rfc3339,
|
bench_datetime_to_rfc3339,
|
||||||
bench_year_flags_from_year,
|
bench_year_flags_from_year,
|
||||||
bench_num_days_from_ce,
|
bench_num_days_from_ce,
|
||||||
|
bench_get_local_time,
|
||||||
);
|
);
|
||||||
|
|
||||||
criterion_main!(benches);
|
criterion_main!(benches);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user