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).
Optimizing MemoWise Performance #ruby #rubydeveloper #rubyonrails #Optimizing #MemoWise #Performance #performance https://rubyonrails.ba/link/optimizing-memowise-performance