-
Notifications
You must be signed in to change notification settings - Fork 19
Refactor to improve performance #34
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
Conversation
|
I should note that this also exposes the |
|
Awesome, appreciate the thoroughness! I will have a look at this later this week. |
|
No rush; we have what we need, I'm just upstreaming the changes because OSS ✨ ❤️ It was a fun exercise, I don't often get challenged to prove/quantify my performance assertions 😉 |
| return parsed | ||
| }, {}) | ||
| if (!interval) { | ||
| return ZERO_INTERVAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a function that returns an object that’s almost always mutable has the potential to be confusing.
| return ZERO_INTERVAL | |
| return { ...ZERO_INTERVAL } |
As raised in #33; this PR improves the performance and readability of the
parsemethod in this library.As requested, I have benchmarked the changes (
benchmark.jsis included in this PR). The results show a 82% increase in performance and reduced memory usage/GC by almost a half.Note the benchmark should be ran with a command line something like the following:
Before:
(Summary: 1226.5 intervals/ms, 7 scavenge GCs)
After:
(Summary: 2231.1 intervals/ms, 4 scavenge GCs)
Full 'before' benchmark results
Full 'after' benchmark results
Closes #33