Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 140783d

Browse files
committed
merge: refactor-ts-parser
This refactored date and time parsing logic is about 3x faster for simple date ('2026-05-01') than the previous "longest first" logic. Overall speed up for journal with only simple dates is around 5-10%. Signed-off-by: 35V LG84 <[email protected]>
2 parents dfc2e37 + 8c7d5fb commit 140783d

2 files changed

Lines changed: 150 additions & 97 deletions

File tree

tackler-core/benches/parser_bench.rs

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,62 @@ use tackler_core::kernel::Settings;
99
use tackler_core::parser::string_to_txns;
1010
use tackler_rs::IndocUtils;
1111

12+
fn cb_ts_date(c: &mut Criterion) {
13+
let mut settings = Settings::default();
14+
15+
#[rustfmt::skip]
16+
let input = "2026-05-01";
17+
18+
c.bench_function("date", |b| {
19+
b.iter(|| {
20+
let res = settings.parse_timestamp(input);
21+
assert!(res.is_ok());
22+
});
23+
});
24+
}
25+
26+
fn cb_ts_datetime(c: &mut Criterion) {
27+
let mut settings = Settings::default();
28+
29+
#[rustfmt::skip]
30+
let input = "2026-05-01T10:01:11";
31+
32+
c.bench_function("datetime", |b| {
33+
b.iter(|| {
34+
let res = settings.parse_timestamp(input);
35+
assert!(res.is_ok());
36+
});
37+
});
38+
}
39+
40+
fn cb_ts_datetime_offset(c: &mut Criterion) {
41+
let mut settings = Settings::default();
42+
43+
#[rustfmt::skip]
44+
let input = "2026-05-01T10:01:11+03:00";
45+
46+
c.bench_function("datetime_offset", |b| {
47+
b.iter(|| {
48+
let res = settings.parse_timestamp(input);
49+
assert!(res.is_ok());
50+
});
51+
});
52+
}
53+
54+
fn cb_ts_datetime_zulu(c: &mut Criterion) {
55+
let mut settings = Settings::default();
56+
57+
#[rustfmt::skip]
58+
let input = "2026-05-01T10:01:11Z";
59+
60+
c.bench_function("datetime_zulu", |b| {
61+
b.iter(|| {
62+
let res = settings.parse_timestamp(input);
63+
assert!(res.is_ok());
64+
});
65+
});
66+
}
67+
1268
fn criterion_benchmark_bare(c: &mut Criterion) {
1369
let mut settings = Settings::default();
1470

@@ -79,6 +135,10 @@ fn criterion_benchmark(c: &mut Criterion) {
79135

80136
criterion_group!(
81137
benches,
138+
cb_ts_date,
139+
cb_ts_datetime,
140+
cb_ts_datetime_zulu,
141+
cb_ts_datetime_offset,
82142
criterion_benchmark_bare,
83143
criterion_benchmark_header,
84144
criterion_benchmark

0 commit comments

Comments
 (0)