Show HN: A faster day-count to Y,M,D algorithm – 30-40% speedup
Mood
informative
Sentiment
positive
Category
startup_launch
Key topics
Date-Algorithm
Optimization
Performance-Improvement
While it is rarely a bottleneck, it is a very frequently run algorithm, and thus has attracted a lot of attention over the years.
In 2021, Cassio Neri and Lorenz Schneider developed the Neri-Schneider algorithm, which was a major breakthrough in this niche area.
Lately, I have been studying this function deeply, and found what I believe may be the last remaining substantial improvements achievable on current hardware. The gains come mainly from counting dates backwards, and from reducing the number of multiplications from 7 to 4.
Adoption will depend on whether library maintainers consider the performance benefit to outweigh the readability. If this is rejected on readability grounds, then in those cases my algorithm outlined in Article 1 (linked in the blog post navigation) is likely to be simpler and faster than what almost all existing libraries are currently doing.
I found this a very interesting challenge to work on, and I believe some of the techniques outlined may be applicable to other areas of optimisation.
Discussion Activity
No activity data yet
We're still syncing comments from Hacker News.
Generating AI Summary...
Analyzing up to 500 comments to identify key contributors and discussion patterns
Discussion hasn't started yet.
Want the full context?
Jump to the original sources
Read the primary article or dive into the live Hacker News thread when you're ready.