https://github.com/jekyll/jekyll
Raw File
Tip revision: 177c1ca09e1be5f8a2924aed6c74bfa7d53079c5 authored by Pat Hawks on 13 August 2018, 18:11:58 UTC
Cache all the things!
Tip revision: 177c1ca
proc-call-vs-yield
#!/usr/bin/env ruby
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