-
Notifications
You must be signed in to change notification settings - Fork 75
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
Speed up transforms by caching the transform class instances. #570
Conversation
For simple transforms, calculate them with less object creations.
Current coverage is 72.40%@@ master #570 diff @@
==========================================
Files 81 81
Lines 7057 7069 +12
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
+ Hits 4991 5118 +127
+ Misses 2066 1951 -115
Partials 0 0
|
Removed code that is not reachable. Changed errors to throw new Error() rather than just strings.
* be rapidly switching between a large number of transforms, this is adequate | ||
* simple behavior. */ | ||
var maxTransformCacheSize = 10; | ||
|
||
var transform = function (options) { |
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.
@manthey does it make sense to have a generic cache object?
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.
Do you mean a generic cache for things besides transform? Or something else?
In general, we use only two or four transforms, so caching those in a module-level object is fine. Invalidating the cache when it reaches a certain size (rather than doing it via LRU) is quick and simple, and, since we won't generally have lots of transforms active at on time, it should be performant, too.
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.
Do you mean a generic cache for things besides transform
Yes generic cache object since we have been caching multiple things now and I feel like we could use something like that (not for this PR though).
LGTM |
For simple transforms, calculate them with less object creations.