## Result [plain_text]
user system total real
yield18.3000000.12000018.420000(19.408501)
block 41.8900000.32000042.210000(44.572319)Proc.new38.5600000.28000038.840000(41.083233)## Benchmarking code [ruby]
require'benchmark'TIMES=10_000_000defthrice_yield3.times {yield}enddefthrice_block&block3.times &block
enddefthrice_proc_dot_new3.times &Proc.new# Yes, you can do that.
end
print ""# Prettiness :3
Benchmark.bm do |bm|
bm.report " yield"do
TIMES.times do
thrice_yield {a =1}endend
bm.report " block"do
TIMES.times do
thrice_block {a =1}endend
bm.report "Proc.new"do
TIMES.times do
thrice_proc_dot_new {a =1}endendend