2 ms·
JavaScript Memoization Libraries: How fast (or slow) they are
- rektide 4y agoSide note, makes me miss jsperf so bad, what a great site for having small tests that then hundreds of people would run & build off of. But even that didn't have npm support. Sonic-memoize is just in a different league. Almost unbelievable. Has a lru cache impl too?! Thus far seems to not have any dependees on it though & tiny download count. Seems almost fishy. https://www.npmjs.com/package/sonic-memoize?activeTab=dependents https://www.npmjs.com/package/sonic-memoize?activeTab=depend... Code looks fine though. I'm surprised it's so much blisteringly faster!
- animus-tom 4y agoIt's just a very new and therefore unknown package. We were suprised about the benchmarkings too. Turns out some libs benchmark their memoization by feeding the memoized functions with one and the same argument millions of times. If you hit the memoized functions with a set of say 1000 different arguments in a loop it turns out some implementations get slow (maybe some O(n) algorithms under the hood where there could have been O(1)).