Optimizing MemoWise Performance

22-Jul-2021 1325
There’s a new gem in town! It’s a memoization gem called MemoWise (pun very much intended) and we think it’s the best way to memoize methods in Ruby. This post covers how we made it so fast, and you can also read our other posts about its origin story and some advanced Ruby tricks we learned along the way.Benchmark Driven DevelopmentWe began by writing benchmark code for our gem so that at any time we could see how performant it was. We decided to explicitly optimize for memoized value retrieval, so our benchmarks only test the speed at which an already-memoized method’s results are returned on subsequent method calls. Because we memoize many different methods in our codebase, we also ensured our benchmarks cover many parameter types and combinations—from def method1 to def method2(a, *b, c:, **d).
Use coupon code:

RUBYONRAILS

to get 30% discount on our bundle!
Prepare for your next tech interview with our comprehensive collection of programming interview guides. Covering JavaScript, Ruby on Rails, React, and Python, these highly-rated books offer thousands of essential questions and answers to boost your interview success. Buy our 'Ultimate Job Interview Preparation eBook Bundle' featuring 2200+ questions across multiple languages. Ultimate Job Interview Preparation eBook Bundle