Skip to content

Commit 1230e55

Browse files
5225225pyfisch
authored andcommitted
Add all date formats to the benchmark
1 parent 8bc58ae commit 1230e55

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

benches/benchmarks.rs

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,27 @@
11
use criterion::{black_box, Criterion, criterion_group, criterion_main};
22

3-
pub fn criterion_benchmark(c: &mut Criterion) {
4-
c.bench_function("parse_http_date", |b| {
3+
pub fn parse_imf_fixdate(c: &mut Criterion) {
4+
c.bench_function("parse_imf_fixdate", |b| {
55
b.iter(|| {
6-
let d = black_box("Wed, 21 Oct 2015 07:28:00 GMT");
6+
let d = black_box("Sun, 06 Nov 1994 08:49:37 GMT");
7+
black_box(httpdate::parse_http_date(d)).unwrap();
8+
})
9+
});
10+
}
11+
12+
pub fn parse_rfc850_date(c: &mut Criterion) {
13+
c.bench_function("parse_rfc850_date", |b| {
14+
b.iter(|| {
15+
let d = black_box("Sunday, 06-Nov-94 08:49:37 GMT");
16+
black_box(httpdate::parse_http_date(d)).unwrap();
17+
})
18+
});
19+
}
20+
21+
pub fn parse_asctime(c: &mut Criterion) {
22+
c.bench_function("parse_asctime", |b| {
23+
b.iter(|| {
24+
let d = black_box("Sun Nov 6 08:49:37 1994");
725
black_box(httpdate::parse_http_date(d)).unwrap();
826
})
927
});
@@ -19,5 +37,5 @@ pub fn encode_date(c: &mut Criterion) {
1937
});
2038
}
2139

22-
criterion_group!(benches, criterion_benchmark, encode_date);
40+
criterion_group!(benches, parse_imf_fixdate, parse_rfc850_date, parse_asctime, encode_date);
2341
criterion_main!(benches);

0 commit comments

Comments
 (0)