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 performance problem from throwing/catching lots of exceptions #242

Merged
merged 1 commit into from
Mar 29, 2021

Conversation

jimrandomh
Copy link
Contributor

runGetter is an inner-loop function that gets called every time anything is imported, and it showed up as a hotspot (~150ms) in my browser Javascript profiler results. Turns out, getter is sometimes null, which means that the small try/catch block here generates and consumes a null-reference exception. This is slow, much slower than handling the null case directly. Doing this reduces the time spent in this function to a much more reasonable ~30ms.

@crapthings
Copy link
Contributor

same here

benjamn/install#60

we can even rewrite forEach to for loop

Copy link
Owner

@benjamn benjamn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea—thanks @jimrandomh!

@benjamn benjamn merged commit 26316b9 into benjamn:master Mar 29, 2021
@benjamn benjamn mentioned this pull request Mar 29, 2021
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.

3 participants