View rubyconf_benchmarks.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
require "json" | |
require "tempfile" | |
require "set" | |
require "benchmark/ips" | |
# Welcome to the benchmarks for "Achieving Fast Method Metaprogramming: Lessons | |
# from MemoWise" by Jacob Evelyn and Jemma Issroff, presented at RubyConf 2021. |
View ruby_memo_wise_memoization.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Example | |
prepend MemoWise | |
def slow_value | |
... | |
end | |
memo_wise :slow_value | |
end |
View ruby_or_equals_memoization.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Example | |
def slow_value | |
@slow_value ||= begin | |
... | |
end | |
end | |
end |