-
Notifications
You must be signed in to change notification settings - Fork 879
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
Weird performance behavior #370
Comments
The root cause for this is the use of trailing whitespace regexp:
This regexp is called every time turndown appends new content to the overall output. And it makes sense why this is getting slower when the output gets longer - the regexp has to go through the whole output just to check few characters at the end of the string. I tried quick and dirty patch just to test the performance impact: With the following result (appending 20000 I leave it to @martincizek or @domchristie to decide whether it makes sense to get rid of the regexp. I think we should replace it because just from the technical point of view it is quite ugly to match few characters at the end of potentially massive output with regexp that has to walk through every character (counterargument might be that this is not a standard use case)... |
@pavelhoral Can you please re-run your performance test with PR #371 applied? |
@martincizek Performance of your change is the same as with my quick patch. 👍 |
@pd4d10 Now I get:
Until a new version is published to npm, you can test it by installing turndown as: "dependencies": {
"turndown": "github:domchristie/turndown"
} |
Fixed in 7.1.1. |
In my machine (Mac mini (M1, 2020)) the log is as follows:
The time spent does not seem to increase linearly. When the image tag count reaches about 10,000, it takes about 7s and caused serious performance problems.
The text was updated successfully, but these errors were encountered: