fast-memoize.js icon indicating copy to clipboard operation
fast-memoize.js copied to clipboard

Is fast-memoize still the best memoization lib? Is it being maintained?

Open theahura opened this issue 2 years ago • 3 comments

Basically the title! Curious if there is some new state-of-the-art for fast memoization, or if this library is still best in class.

theahura avatar Jan 06 '23 06:01 theahura

The benchmarking implemented here only tests for the memoized function to be called with one and the same argument (or only a handful of arguments) over and over again. If you test with more different arguments the results for fast-memoize are quite different. Check out our benchmarks here: https://github.com/Animus-Blue/sonic-memoize We implemented benchmarking with a set of 1000 different arguments. So for the first 1000 function calls the memoized function is calling the original expensive function under the hood and all consecutive function calls hit the cache.

ThomasF85 avatar Mar 16 '23 20:03 ThomasF85

Sonic-memoize does look fast based on those benchmarks. I ended up going with memoizee based on a combination of benchmarks and how much usage it had.

I wanted to just stick to lodash, but the syntax for multi argument memoization is gross.

bellmatthewf avatar Jun 27 '23 23:06 bellmatthewf

Did few benchmark and fast-memoize was slower than lodash memoize on most of the functions benchmarked on my code base, your use case might be different tho, better to benchmark and then decide. Worth mentioning sonic-memoize was the fastest for my usecase.

func 1 // no cache a: 1.141s // memoizee a: 368.892ms // fast-memoize a: 4.047s // lodash-memoize a: 335.994ms // sonic-memoize: a: 241.388ms

func 2 // no cache a: 1.551s // memoizee a: 1.558s // fast-memoize a: 1.763s // lodash-memoize a: 1.925s //sonic-memoize a: 551.161ms

binary-signal avatar Aug 23 '23 15:08 binary-signal