Files
jekyll/benchmark/proc-call-vs-yield
fen 7729d12cdc include a hashbang for all benchmark scripts
this also makes every benchmark script executable
2016-10-22 03:13:30 +02:00

16 lines
222 B
Ruby
Executable File

#!/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