Skip to content

improve naive datetime handling in rowbinary#311

Merged
ruslandoga merged 1 commit intomasterfrom
improve-naive-datetime
Apr 20, 2026
Merged

improve naive datetime handling in rowbinary#311
ruslandoga merged 1 commit intomasterfrom
improve-naive-datetime

Conversation

@ruslandoga
Copy link
Copy Markdown
Collaborator

No description provided.

@ruslandoga ruslandoga force-pushed the improve-naive-datetime branch from 1f7ac2a to 37416ba Compare April 20, 2026 18:03
"DateTime64(6) now" => {_time_unit = 1_000_000, NaiveDateTime.utc_now()},
"DateTime64(9) now" => {_time_unit = 1_000_000_000, NaiveDateTime.utc_now()}
}
)
Copy link
Copy Markdown
Collaborator Author

@ruslandoga ruslandoga Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread bench/datetime_encode.exs
inputs: %{
"now" => NaiveDateTime.utc_now()
}
)
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@ruslandoga ruslandoga force-pushed the improve-naive-datetime branch from b13f930 to 2ec5493 Compare April 20, 2026 19:27
@ruslandoga ruslandoga merged commit 4a0fa01 into master Apr 20, 2026
4 of 6 checks passed
@ruslandoga ruslandoga deleted the improve-naive-datetime branch April 20, 2026 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant