Skip to content

Instantly share code, notes, and snippets.

@JacobEvelyn
JacobEvelyn / rubyconf_benchmarks.rb
Last active Nov 10, 2021
"Achieving Fast Method Metaprogramming: Lessons from MemoWise" from RubyConf 2021
View rubyconf_benchmarks.rb
# 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
class Example
prepend MemoWise
def slow_value
...
end
memo_wise :slow_value
end
View ruby_or_equals_memoization.rb
class Example
def slow_value
@slow_value ||= begin
...
end
end
end