Skip to content

Instantly share code, notes, and snippets.

@omerfarukdemir
Created January 18, 2019 12:52
Show Gist options
  • Save omerfarukdemir/b3fb1625c959c53c73bfbaa11ccd8d25 to your computer and use it in GitHub Desktop.
Save omerfarukdemir/b3fb1625c959c53c73bfbaa11ccd8d25 to your computer and use it in GitHub Desktop.
require "benchmark"
iteration = 10000000
Benchmark.bm do |bm|
bm.report("method") do
class RPC0
def new_address
"0"
end
end
iteration.times do
RPC0.new.new_address
end
end
bm.report("method_missing") do
class RPC1
def method_missing(_method, *_args)
"0"
end
def respond_to_missing?(method_name, include_private = false)
super
end
end
iteration.times do
RPC1.new.new_address
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment