jiff/crates/jiff-static
Andrew Gallant 269aee43ef
shared: attempt a faster date <-> rate die algorithm
This comes from:
https://www.benjoffe.com/fast-date-64

More specifically, the code is here:
7fcf82b07d/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/critcmp
2025-11-26 14:31:58 -05:00
..
src shared: attempt a faster date <-> rate die algorithm 2025-11-26 14:31:58 -05:00
Cargo.toml 0.2.16 2025-11-07 07:53:58 -05:00
COPYING jiff-tz-static: add initial version of new proc macro 2025-02-26 16:55:17 -05:00
LICENSE-MIT jiff-tz-static: add initial version of new proc macro 2025-02-26 16:55:17 -05:00
README.md jiff-static: improve README 2025-03-10 07:54:20 -04:00
UNLICENSE jiff-tz-static: add initial version of new proc macro 2025-02-26 16:55:17 -05:00

jiff-static

This is an optional dependency of jiff that embeds time zone data into your binary via procedural macros. It unlocks the use case of creating a TimeZone value in core-only environments without dynamic memory allocation.

Users should generally not depend on this directly, but instead use it through Jiff. Namely, all of the procedural macros defined in this crate are re-exported through Jiff's public API. For example, one can enable the static or static-tz crate features in jiff to get jiff::tz::get! and jiff::tz::include!.

WARNING: The src/shared directory in this crate is copied from the ../src/shared directory. This copy is managed by jiff-cli generate shared. See the comments in the code for why this is done.

Documentation

https://docs.rs/jiff-static