sibanu_web/public/assets/vendor/jekyll/benchmark/proc-call-vs-yield

15 lines
202 B
Plaintext
Raw Normal View History

2022-08-20 13:21:23 +07:00
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