Skip to content
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

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

Open
theahura opened this issue Jan 6, 2023 · 3 comments
Open

Comments

@theahura
Copy link

theahura commented Jan 6, 2023

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.

@ThomasF85
Copy link

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.

@bellmatthewf
Copy link

bellmatthewf commented Jun 27, 2023

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.

@binary-signal
Copy link

binary-signal commented Aug 23, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants