[performance] new Intl.NumberFormat is slow
Closed this issue · 1 comments
t2ym commented
[performance] new Intl.NumberFormat
is slow
Possible Fix
- Since
new Intl.NumberFomrat
is called withlang
andoptions
, observe these parameters and cache thenew Intl.NumberFormat(lang, options)
object for later usage - The expected reliable caching algorithm is not as simple as expected with performance in consideration.
Notes
- Just calling
.format()
method is 100 times faster than instantiatingIntl.NumberFormat
on each call - The fix priority is low since
<i18n-number>
should not be used so heavily
t2ym commented
Notes
- This fix is not ultimate but effective enough. The performance of
render()
is more than 13 times higher than the original.