Luxon: Luxon is very slow compared to moment

Created on 17 Aug 2018  路  4Comments  路  Source: moment/luxon

I moved on to use Luxon and felt its API very well. But the performance is also a factor to concern, so I did a small test:
moment('2018-01-01').format('YYYYMMDD')
vs
luxon.DateTime.fromISO('2018-01-01').toFormat('YYYYMMDD')
repeart 10000 times.

Link: https://codepen.io/thetuyen/pen/ejqMVp?editors=1000
Using performance tool of chrome, results:
capture

With formatting luxon slower than moment from 15 to 20 times. I was thought luxon would be faster!

performance

Most helpful comment

The problem here is that Luxon is choosing to use the Intl API to generate the strings here instead of its hardcoded English strings. Intl is really slow, so the call is slow. Since you haven't set any locale info, Luxon should be able to do this without Intl work, so this is a bug.

All 4 comments

The problem here is that Luxon is choosing to use the Intl API to generate the strings here instead of its hardcoded English strings. Intl is really slow, so the call is slow. Since you haven't set any locale info, Luxon should be able to do this without Intl work, so this is a bug.

Now that I've finally gone and looked at this, that wasn't the problem at all. The problem is that you used "YYYYMMDD", when you meant "yyyyMMdd". "DD" means "localized date with abbreviated month" (see here). That requires Intl to compute, even in English.

Once fixed, still a little slower, but not by much:

image

Now that I've finally gone and looked at this, that wasn't the problem at all. The problem is that you used "YYYYMMDD", when you mean "yyyyMMdd". "DD" means something "medium local date format", which requires Intl to compute.

Today I learn this

This is ridiculous. How can a native module be so shitty....

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pmcilreavy picture pmcilreavy  路  6Comments

zbraniecki picture zbraniecki  路  6Comments

Frondor picture Frondor  路  5Comments

peterjanes picture peterjanes  路  5Comments

UnsungHero97 picture UnsungHero97  路  5Comments