Skip to content

Instantly share code, notes, and snippets.

@JacobEvelyn
JacobEvelyn / rubyconf_benchmarks.rb
Last active June 7, 2023 07:00
"Achieving Fast Method Metaprogramming: Lessons from MemoWise" from RubyConf 2021
# 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.
@JacobEvelyn
JacobEvelyn / ruby_memo_wise_memoization.rb
Created June 30, 2021 14:48
MemoWise Ruby memoization
class Example
prepend MemoWise
def slow_value
...
end
memo_wise :slow_value
end
@JacobEvelyn
JacobEvelyn / ruby_or_equals_memoization.rb
Last active June 30, 2021 14:45
||= Ruby memoization
class Example
def slow_value
@slow_value ||= begin
...
end
end
end