Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused code in parsing and speed parsing up #53

Merged
merged 1 commit into from
Aug 15, 2024

Conversation

anowacki
Copy link
Collaborator

The NanoDate(::AbstractString, ::DateFormat) constructor previously
created a few variables which are never used, so remove these lines.
These lines are actually responsible for about half the running time of
calls to the constructor, so this change doubles the speed of parsing.

Also remove the unused separate_offset methods.

The `NanoDate(::AbstractString, ::DateFormat)` constructor previously
created a few variables which are never used, so remove these lines.
These lines are actually responsible for about half the running time of
calls to the constructor, so this change doubles the speed of parsing.

Also remove the unused `separate_offset` methods.
@anowacki
Copy link
Collaborator Author

Before (v1.0.2):

julia> @benchmark NanoDate("1234-01-02T01:23:45.123456789+01:23")
BenchmarkTools.Trial: 10000 samples with 3 evaluations.
 Range (min … max):  8.617 μs … 28.051 μs  ┊ GC (min … max): 0.00% … 0.00%
 Time  (median):     9.091 μs              ┊ GC (median):    0.00%
 Time  (mean ± σ):   9.873 μs ±  1.543 μs  ┊ GC (mean ± σ):  0.00% ± 0.00%

  ▁▆██▇▆▄▂      ▁▃▃▃▃▂▁ ▁▁▁▂▂▃▃▃▂▂▁▁▁▁▁▂▁▁▁                  ▂
  █████████▇▇▇█████████████████████████████████▆▇█▇▇▇▇▇▇▆▆▅▅ █
  8.62 μs      Histogram: log(frequency) by time     14.9 μs <

 Memory estimate: 2.66 KiB, allocs estimate: 52.

After (016ccae):

julia> @benchmark NanoDate("1234-01-02T01:23:45.123456789+01:23")
BenchmarkTools.Trial: 10000 samples with 7 evaluations.
 Range (min … max):  5.056 μs …  10.450 μs  ┊ GC (min … max): 0.00% … 0.00%
 Time  (median):     5.241 μs               ┊ GC (median):    0.00%
 Time  (mean ± σ):   5.297 μs ± 325.704 ns  ┊ GC (mean ± σ):  0.00% ± 0.00%

    ▃██▅                                                       
  ▃▆█████▅▃▃▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▁▂▂▁▁▁▁▂▂▂▁▂▂▁▁▁▁▁▁▁▁▁▁▂▂▂▂▂▂▂ ▃
  5.06 μs         Histogram: frequency by time        7.51 μs <

 Memory estimate: 1.88 KiB, allocs estimate: 43.

@JeffreySarnoff
Copy link
Member

Much appreciated.

@JeffreySarnoff JeffreySarnoff merged commit 089fa29 into main Aug 15, 2024
3 checks passed
@JeffreySarnoff JeffreySarnoff deleted the an/remove-unused branch August 15, 2024 20:10
JeffreySarnoff added a commit that referenced this pull request Aug 15, 2024
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.

2 participants