improve naive datetime handling in rowbinary#311
Merged
ruslandoga merged 1 commit intomasterfrom Apr 20, 2026
Merged
Conversation
1f7ac2a to
37416ba
Compare
ruslandoga
commented
Apr 20, 2026
| "DateTime64(6) now" => {_time_unit = 1_000_000, NaiveDateTime.utc_now()}, | ||
| "DateTime64(9) now" => {_time_unit = 1_000_000_000, NaiveDateTime.utc_now()} | ||
| } | ||
| ) |
Collaborator
Author
There was a problem hiding this comment.
Operating System: macOS
CPU Information: Apple M2
Number of Available Cores: 8
Available memory: 8 GB
Elixir 1.19.5
Erlang 28.3
JIT enabled: true
Benchmark suite executing with the following configuration:
warmup: 2 s
time: 5 s
memory time: 0 ns
reduction time: 0 ns
parallel: 1
inputs: DateTime64(3) now, DateTime64(6) now, DateTime64(9) now
Estimated total run time: 42 s
Excluding outliers: false
Benchmarking naive_diff with input DateTime64(3) now ...
Benchmarking naive_diff with input DateTime64(6) now ...
Benchmarking naive_diff with input DateTime64(9) now ...
Benchmarking to_gregorian_diff with input DateTime64(3) now ...
Benchmarking to_gregorian_diff with input DateTime64(6) now ...
Benchmarking to_gregorian_diff with input DateTime64(9) now ...
Calculating statistics...
Formatting results...
##### With input DateTime64(3) now #####
Name ips average deviation median 99th %
to_gregorian_diff 11.21 M 89.25 ns ±3499.31% 83 ns 125 ns
naive_diff 5.03 M 198.86 ns ±3506.79% 167 ns 292 ns
Comparison:
to_gregorian_diff 11.21 M
naive_diff 5.03 M - 2.23x slower +109.61 ns
##### With input DateTime64(6) now #####
Name ips average deviation median 99th %
to_gregorian_diff 14.46 M 69.15 ns ±2799.11% 58.30 ns 104.20 ns
naive_diff 4.98 M 200.90 ns ±3366.56% 167 ns 292 ns
Comparison:
to_gregorian_diff 14.46 M
naive_diff 4.98 M - 2.91x slower +131.75 ns
##### With input DateTime64(9) now #####
Name ips average deviation median 99th %
to_gregorian_diff 9.37 M 106.71 ns ±4025.07% 84 ns 167 ns
naive_diff 4.58 M 218.11 ns ±2008.17% 208 ns 333 ns
Comparison:
to_gregorian_diff 9.37 M
naive_diff 4.58 M - 2.04x slower +111.40 ns
ruslandoga
commented
Apr 20, 2026
| inputs: %{ | ||
| "now" => NaiveDateTime.utc_now() | ||
| } | ||
| ) |
Collaborator
Author
There was a problem hiding this comment.
Operating System: macOS
CPU Information: Apple M2
Number of Available Cores: 8
Available memory: 8 GB
Elixir 1.19.5
Erlang 28.3
JIT enabled: true
Benchmark suite executing with the following configuration:
warmup: 2 s
time: 5 s
memory time: 0 ns
reduction time: 0 ns
parallel: 1
inputs: now
Estimated total run time: 21 s
Excluding outliers: false
Benchmarking naive_diff with input now ...
Benchmarking to_gregorian_diff with input now ...
Benchmarking to_utc_to_unix with input now ...
Calculating statistics...
Formatting results...
##### With input now #####
Name ips average deviation median 99th %
to_gregorian_diff 10.83 M 92.37 ns ±7675.29% 83 ns 167 ns
naive_diff 6.88 M 145.38 ns ±3996.24% 125 ns 250 ns
to_utc_to_unix 5.31 M 188.25 ns ±3012.06% 167 ns 333 ns
Comparison:
to_gregorian_diff 10.83 M
naive_diff 6.88 M - 1.57x slower +53.02 ns
to_utc_to_unix 5.31 M - 2.04x slower +95.89 ns
b13f930 to
2ec5493
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.