Skip to content

Instantly share code, notes, and snippets.

@BitOfUniverse
Created March 8, 2018 14:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BitOfUniverse/00423fbfef86f0d4aedccb01d67df083 to your computer and use it in GitHub Desktop.
Save BitOfUniverse/00423fbfef86f0d4aedccb01d67df083 to your computer and use it in GitHub Desktop.
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