-
Notifications
You must be signed in to change notification settings - Fork 721
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
perf(datetime): toISO 100x faster #1097
Conversation
|
1 similar comment
|
CLA fixed 🙂 |
Thanks, I've been considering this optimization for a while. A few thoughts:
Edited to add:
(I haven't tested those, but I think that's right...) |
For fun, I ported this to my experimental fork of Luxon and found a few things:
Here's what I ended up with (luxon-next is similar code but arranged completely differently): https://github.com/icambron/luxon-next/blob/451129e297c8c7fc8a2501abbd41deda1e9075e3/src/dateTime/format.ts#L203 I haven't benchmarked yet, so maybe there's more to do there. |
d08648f
to
8f68281
Compare
Hi Isaac, thanks for the review! I take one point at a time: From your first message:
From the second one:
You were right, I was missing tests, it should be better now
True, step by step ^^
Done, it changed your implementation slightly to use ('' + v) instead of v.toString() as it is faster
Fixed |
I pulled your branch and added some commits. See #1108. Closing this PR and we can continue over there. |
toISO is very slow compared to the competition: 80x slower than dayjs, 40x slower than momentjs and 50x slower than date-fns.
This implementation makes it 100x faster than before or 125% faster than dayjs.
Please merge 🙂