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
Long text in JSX is slow #3263
Comments
We should profile it, see what's eating up the CPU. |
I did a very quick test, with a large file that took prettier ~3.6s to format, and it looks the first culprit is a call to Lines 58 to 62 in 2332c5c
Which is a very simple code (some Lines 300 to 301 in 2332c5c
Making that algorithm quadratic if I did understood correctly. Removing the check completely reduced the time to ~1.1s. With that out of that way, the 2nd culprit is slicing that very large array in Then I re-added the |
I think we're good now, reduced to about ~20% of the time :-) |
Awesome work on this @duailibe! That is a huge improvement over my naive implementation of |
Thanks! Thankfully the code is really well written it was easy to understand it 😄 |
If you have a lot of text in JSX Prettier is really slow. It takes around 2 seconds to print a file with 1000 lines of text where it takes only 200 ms to print a file with 1000 lines of tags.
The text was updated successfully, but these errors were encountered: