Skip to content
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

fix: optimization getLocaleDate performances #19

Merged
merged 1 commit into from Aug 15, 2021

Conversation

Janlaywss
Copy link
Contributor

Reason

Open the Gantt chart component, found the fps drop, only 23fps minimum

image

Through Chrome Devtools Performance analysis, it is found that longtask is more serious. And toLocaleDateString takes a long time:

image

The toLocaleDateString function takes a long time
image

the root cause seem to be that instantiates a new Intl.DateTimeFormat every time toLocaleString is called, which has a relatively high cost. (moment/luxon#352)

Solution

Since there will only ever be a very limited number of formats, those format instances should be cached after creation. This reduces the runtime of toLocaleString cost by a factor of 10.

Final Results

Through optimization, FPS has been improved by 10%. After the upgrade, the lowest reached 28fps
image

@MaTeMaTuK
Copy link
Owner

Thank you for help with optimisation!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants