15 lines
202 B
Plaintext
15 lines
202 B
Plaintext
|
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
|