Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Ruby benchmark [2.4 vs 2.5]: Lazy Proc allocation for block parameters
require 'benchmark'
def with_block(&block); end
Benchmark.bmbm(10){|x|
x.report("with_block") { 1_000_000.times{ with_block{} } }
}
# Using /Users/alexey/.rvm/gems/ruby-2.4.2
# ➜ ruby ruby benchmark_ruby_block_passing.rb
# user system total real
# with_block 0.550000 0.000000 0.550000 ( 0.553924)
# Using /Users/alexey/.rvm/gems/ruby-2.5.0
# user system total real
# with_block 0.083184 0.000373 0.083557 ( 0.083838)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment