Commit 269aee4
committed
shared: attempt a faster date <-> rate die algorithm
This comes from:
https://www.benjoffe.com/fast-date-64
More specifically, the code is here:
https://github.com/benjoffe/fast-date-benchmarks/blob/7fcf82b07d340ddbec866e15cfe333485439ab7f/algorithms/benjoffe_fast64.hpp
But the benchmarks don't show an improvement:
```
$ critcmp base x01
group base x01
----- ---- ---
civil_datetime/to_timestamp_static/bundled/jiff 1.00 10.5±0.09ns ? ?/sec 1.03 10.9±0.07ns ? ?/sec
civil_datetime/to_timestamp_static/zoneinfo/jiff 1.00 10.4±0.09ns ? ?/sec 1.03 10.8±0.07ns ? ?/sec
timestamp/to_civil_datetime_offset_conversion/jiff 1.00 4.4±0.05ns ? ?/sec 1.03 4.6±0.03ns ? ?/sec
```
I ran the benchmarks like this:
```
cd bench
```
Before the change:
```
cargo bench --'(civil_datetime/to_timestamp_static|timestamp/to_civil_datetime_offset_conversion).*jiff' --save-baseline base
```
And then after the change:
```
cargo bench --'(civil_datetime/to_timestamp_static|timestamp/to_civil_datetime_offset_conversion).*jiff' --save-baseline x01
```
Then I used [`critcmp`] to compare them:
```
critcmp base x01
```
It's very possible I didn't port it correctly. I haven't scrutinized the
codegen. It's also possible that there is an improvement, but that it's
hard to write a benchmark using Jiff APIs to observe it.
(Note that I left out the ARM-specific bits. I'm testing this on x86-64.
I wanted to test there first before digging into the platform specific
optimizations.)
[`critcmp`]: https://github.com/BurntSushi/critcmp1 parent 9d7e099 commit 269aee4
File tree
2 files changed
+86
-74
lines changed2 files changed
+86
-74
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
173 | 173 | | |
174 | 174 | | |
175 | 175 | | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
200 | 207 | | |
| 208 | + | |
| 209 | + | |
201 | 210 | | |
202 | 211 | | |
203 | 212 | | |
| |||
351 | 360 | | |
352 | 361 | | |
353 | 362 | | |
354 | | - | |
355 | | - | |
356 | | - | |
| 363 | + | |
| 364 | + | |
357 | 365 | | |
358 | 366 | | |
359 | 367 | | |
360 | 368 | | |
361 | 369 | | |
362 | | - | |
363 | | - | |
364 | | - | |
365 | | - | |
366 | | - | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
367 | 374 | | |
368 | | - | |
369 | | - | |
370 | | - | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
371 | 379 | | |
372 | | - | |
373 | | - | |
374 | 380 | | |
375 | 381 | | |
376 | 382 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
171 | 171 | | |
172 | 172 | | |
173 | 173 | | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
198 | 205 | | |
| 206 | + | |
| 207 | + | |
199 | 208 | | |
200 | 209 | | |
201 | 210 | | |
| |||
349 | 358 | | |
350 | 359 | | |
351 | 360 | | |
352 | | - | |
353 | | - | |
354 | | - | |
| 361 | + | |
| 362 | + | |
355 | 363 | | |
356 | 364 | | |
357 | 365 | | |
358 | 366 | | |
359 | 367 | | |
360 | | - | |
361 | | - | |
362 | | - | |
363 | | - | |
364 | | - | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
365 | 372 | | |
366 | | - | |
367 | | - | |
368 | | - | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
369 | 377 | | |
370 | | - | |
371 | | - | |
372 | 378 | | |
373 | 379 | | |
374 | 380 | | |
| |||
0 commit comments