This repository was archived by the owner on Dec 12, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbenchmark.rs
More file actions
79 lines (75 loc) · 2.62 KB
/
benchmark.rs
File metadata and controls
79 lines (75 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#![allow(unused)]
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
use time_tests::*;
fn bench_time_parsing(c: &mut Criterion) {
let mut group = c.benchmark_group("OffsetDateTime");
for i in [
"2016-03-07T22:36:55.135+03:30",
"2013-09-17 23:59-01:00",
"2015-11-19 01:01:39+01:00",
"2014-10-18 00:00:38.697+00:00",
"2017-04-11T14:35+02:00",
]
.iter()
{
group.bench_with_input(BenchmarkId::new("1st ITER", i), i, |b, i| {
b.iter(|| first::odt_iteration(*i))
});
group.bench_with_input(BenchmarkId::new("2nd ITER", i), i, |b, i| {
b.iter(|| second::odt_iteration(*i))
});
group.bench_with_input(BenchmarkId::new("3rd ITER", i), i, |b, i| {
b.iter(|| third::odt_iteration(*i))
});
group.bench_with_input(BenchmarkId::new("4th ITER", i), i, |b, i| {
b.iter(|| fourth::odt_iteration(*i))
});
}
group.finish();
let mut group = c.benchmark_group("PrimitiveDateTime");
for i in [
"2018-12-01 04:09:19.543",
"2017-11-30 03:08",
"2011-05-24 21:02Z",
"2019-01-02 05:10:20",
"2013-07-26 23:04:14Z",
"2012-06-25 22:03:13.321Z",
"2014-08-27T00:05",
"2008-02-21T18:59Z",
"2016-10-29T02:07:17",
"2010-04-23T20:01:11Z",
"2015-09-28T01:06:16.432",
"2009-03-22T19:00:10.21Z",
]
.iter()
{
group.bench_with_input(BenchmarkId::new("1st ITER", i), i, |b, i| {
b.iter(|| first::pdt_iteration(*i))
});
group.bench_with_input(BenchmarkId::new("2nd ITER", i), i, |b, i| {
b.iter(|| second::pdt_iteration(*i))
});
group.bench_with_input(BenchmarkId::new("3rd ITER", i), i, |b, i| {
b.iter(|| third::pdt_iteration(*i))
});
group.bench_with_input(BenchmarkId::new("4th ITER", i), i, |b, i| {
b.iter(|| fourth::pdt_iteration(*i))
});
}
group.finish();
let mut group = c.benchmark_group("Time");
for i in ["20:45:31.133", "21:46:32", "19:44"].iter() {
group.bench_with_input(BenchmarkId::new("1st ITER", i), i, |b, i| {
b.iter(|| first::time_iteration(*i))
});
group.bench_with_input(BenchmarkId::new("2nd ITER", i), i, |b, i| {
b.iter(|| second::time_iteration(*i))
});
group.bench_with_input(BenchmarkId::new("3rd ITER", i), i, |b, i| {
b.iter(|| third::time_iteration(*i))
});
}
group.finish();
}
criterion_group!(benches, bench_time_parsing);
criterion_main!(benches);