Skip to content

Use Dates.yearmonthday function where appropriate#72

Merged
felipenoris merged 1 commit intoJuliaFinance:masterfrom
adranka:is_holiday_perf_improvements
Mar 25, 2026
Merged

Use Dates.yearmonthday function where appropriate#72
felipenoris merged 1 commit intoJuliaFinance:masterfrom
adranka:is_holiday_perf_improvements

Conversation

@adranka
Copy link
Copy Markdown
Contributor

@adranka adranka commented Mar 19, 2026

Use Dates.yearmonthday to simultaneously get the year, month, and day. This slightly improves performance:

Before:

julia> using BenchmarkTools

julia> using BusinessDays

julia> using Dates

julia> cal = BusinessDays.USSettlement();

julia> d = Date(2026, 1, 2);

julia> @btime isholiday($cal, $d);
  385.911 ns (0 allocations: 0 bytes)

julia> d = Date(2026, 1, 1);

julia> @btime isholiday($cal, $d);
  88.467 ns (0 allocations: 0 bytes)

After:

julia> d = Date(2026, 1, 2);

julia> @btime isholiday($cal, $d);
  348.192 ns (0 allocations: 0 bytes)

julia> d = Date(2026, 1, 1);

julia> @btime isholiday($cal, $d);
  50.441 ns (0 allocations: 0 bytes)

@felipenoris
Copy link
Copy Markdown
Collaborator

Awesome!

@felipenoris felipenoris merged commit bbc0c63 into JuliaFinance:master Mar 25, 2026
16 checks passed
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