https://github.com/jekyll/jekyll
Raw File
Tip revision: 6baccbc43ebb770aacf3d8e2575e361871094e13 authored by Jordon Bedwell on 14 May 2016, 00:33:41 UTC
Create an un-mergable commit to demonstrate Pathutil.
Tip revision: 6baccbc
proc-call-vs-yield
require 'benchmark/ips'

def fast
  yield
end

def slow(&block)
  block.call
end

Benchmark.ips do |x|
  x.report('yield') { fast { (0..9).to_a } }
  x.report('block.call') { slow { (0..9).to_a } }
end
back to top