Actions
Misc #10983
closedWhy blocks make Ruby methods 439% slower ?
Misc #10983:
Why blocks make Ruby methods 439% slower ?
Status:
Closed
Assignee:
-
Description
https://www.omniref.com/ruby/2.2.0/symbols/Proc/yield#annotation=4087638&line=711&hn=1
require 'benchmark/ips'
def block_call(&block)
block.call
end
def just_yield
yield
end
Benchmark.ips do |x|
x.report("call") do
block_call { 1 + 1 }
end
x.report("just yield") do
just_yield { 1 + 1 }
end
x.compare!
end
I run on Ruby 2.2.1
Actions