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

Mdf performance and docs #1438

Merged
merged 10 commits into from Feb 14, 2024
Merged

Mdf performance and docs #1438

merged 10 commits into from Feb 14, 2024

Conversation

pitdicker
Copy link
Collaborator

The Mdf types reason for existence is to have a way to convert between ordinal dates and month-day dates efficiently. It is a core part of the performance of chrono, we use it internally all over the place. Before converting it to return Results in the 0.5 branch I need a benchmark to not materially regress its performance.

Turns out I already regressed it by ca. 25% (at least according to the new benchmark) since chrono 0.4.24 😱.
After the benchmark in the first commit, the next three commits recover this lost performance by reverting needless checks:

Then there are two commits that improve the performance a little bit more.
And while working on it I wrote some doc comments for the methods on Mdf.

Benchmark results

Chrono 0.4.24

bench_date_from_ymd     time:   [4.3541 ns 4.3737 ns 4.3958 ns]

Before

bench_date_from_ymd     time:   [5.5149 ns 5.5508 ns 5.5919 ns]

After

bench_date_from_ymd     time:   [4.2512 ns 4.2572 ns 4.2637 ns]

I have the commits that extend this PR to convert an Mdf to return Results ready, but would like to base them on this PR to the main branch.

Copy link

codecov bot commented Feb 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (4d4ff14) 91.85% compared to head (81a52a9) 91.86%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1438   +/-   ##
=======================================
  Coverage   91.85%   91.86%           
=======================================
  Files          40       40           
  Lines       17469    17471    +2     
=======================================
+ Hits        16046    16049    +3     
+ Misses       1423     1422    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@pitdicker
Copy link
Collaborator Author

pitdicker commented Feb 13, 2024

I rebased the documentation commit to be earlier in the PR, that should make reviewing a bit easier.

And there was one commit I had left after the internals refactor that makes the constants used in YearFlags less magical and updates the documentation. It kind of seems to fit in with this PR (as the other half of this file).

@pitdicker
Copy link
Collaborator Author

Nice, thank you!

@pitdicker pitdicker merged commit 21343be into chronotope:main Feb 14, 2024
37 checks passed
@pitdicker pitdicker deleted the mdf branch February 14, 2024 09:59
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.

None yet

2 participants