Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I would strongly recommend against using fast-memoize in these docs. It will jsonify the incoming argument parameters. The user is likely to be memoizing against large state objects. The cost of stringifying these large objects could easily outweigh the performance benefits of memoization.
fast-memoize
is well benchmarked for use cases when you are memoizing a function which takes small integers as arguments.fast-memoize
benchmarking also does not incorporate key deletion or any polymorphic pressure exerted on the engine. For easy peasy, most of the time in my experience, you are memoizing large objects as keys in the memoized cache. Memoizerific and other memoization libraries are able to cache objects effectively because the javascript engine stores a random ID on every object and ES6Map
is able to use that ID. Therefore object lookup in aMap
will amount to an integer comparison whereas withfast-memoize
this comparison will amount to serializing the entire object and then comparing long strings.