A

A faster day-count to Y,M,D algorithm – 30-40% speedup

Hacker News

A faster day-count to Y,M,D algorithm – 30-40% speedup

Converting that integer to a Year, Month and Day is a fundamental calculation made in almost all programming languages and standard libraries. It runs every time a date is displayed, whether it's in a user interface, log, API etc. 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.

Share card

Actual performance

3points
Did not reach leaderboard

Launch Intel predictions

Analyze your own launch →
Indie HackersFits the IH revenue-focused audience · Missing: supports, reddit linkedin, podcasting
71%71% predicted probability of success on Indie Hackers, based on ML models trained on real launch data.
Hacker NewsStrong engagement from HN community · Strong signals: exist, existing, ide · Missing: https docs, excited, just released
69%69% predicted probability of success on Hacker News, based on ML models trained on real launch data.
nativeThis product was originally launched on this platform.
Product HuntOn track for Day 1 leaderboard · Strong signals: user · Missing: mac, agents, macos
68%68% predicted probability of success on Product Hunt, based on ML models trained on real launch data.
TrustMRRFits verified-revenue profile · Strong signals: month · Missing: mobile apps, ios, personal
60%60% predicted probability of success on TrustMRR, based on ML models trained on real launch data.
AppSumoMay struggle as an AppSumo deal · Strong signals: interface · Missing: plus, platform, intuitive
35%35% predicted probability of success on AppSumo, based on ML models trained on real launch data.
Acquire.comPre-revenue stage for this audience · Missing: arr, mrr, revenue
27%27% predicted probability of success on Acquire.com, based on ML models trained on real launch data.
BetaListMay not resonate with beta-testers · Missing: web3, chat, crypto
0%0% predicted probability of success on BetaList, based on ML models trained on real launch data.

Incorrect prediction on native model

Similar products

BM
BM25opt – 30-40 x faster BM25 search algorithms (FOSS)65%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

BM25opt – 30-40 x faster BM25 search algorithms (FOSS)

Hacker News1
Cy
Cython implementation of DeepWalk algorithm46%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Cython implementation of DeepWalk algorithm

Hacker News2
Il
Illustrated Quicksort algorithm50%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Illustrated Quicksort algorithm

Hacker News187
Pr
Prim's algorithm50%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Prim's algorithm

Hacker News5
DF
DFA Minimization by Hopcroft's Algorithm in Go50%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

DFA Minimization by Hopcroft's Algorithm in Go

Hacker News2
Po
Polyline Encoding Algorithm in Dart38%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Polyline Encoding Algorithm in Dart

Hacker News1
Ma
Mandelwave: A mandelbrot inverse spectrogram with Griffin-Lim algorithm50%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Mandelwave: A mandelbrot inverse spectrogram with Griffin-Lim algorithm

Hacker News4
Go
Go implementation of Welford's algorithm for weighted variance46%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Go implementation of Welford's algorithm for weighted variance

Hacker News11
Di
Distributed Genetic Algorithm in Clojure70%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Distributed Genetic Algorithm in Clojure

Hacker News1
K-
K-means algorithm in Ruby56%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

K-means algorithm in Ruby

Hacker News5