Closed barakplasma closed 1 year ago
Turns out that skipping the step where I turn the string into a Date object leads to greater performance in moment js and the others. It also allows me to do a manual formatting via substrings, which is 100x faster.
You can see this at https://5b789027b31274296266b067--objective-ptolemy-a7f7c2.netlify.com/ this version of the deployed artifact.
const many_dates = Array(10).fill(0).map(() => new Date()).map(d => d.toISOString());
via https://jsperf.com/date-formatting-library-performance Caveat: I noticed that the version I wrote doesn't account for the time zone, and the format is slightly off in regards to the number of digits on the hour place. Easy fixes, but not my cup of tea at this hour.
I noticed in the Chrome Javascript profiler that the native method is the slowest. When I ran a performance test, I noticed that moment.js is actually the fastest. https://jsperf.com/date-formatting-library-performance/1
Go figure.
TODO: use Moment.js instead of native for higher performance