Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
11 lines (9 sloc) 410 Bytes
require 'benchmark'
Benchmark.bmbm do |bm|
bm.report("Control") { 10_000_000.times { 1 + 1 } }
bm.report("instance_eval a block") { 10_000_000.times { instance_eval { 1 + 1 } } }
if defined? instance_exec
bm.report("instance_exec a block") { 10_000_000.times { instance_exec { 1 + 1 } } }
end
bm.report("instance_eval a string (* 0.1 times)") { 1_000_000.times { instance_eval " 1 + 1 " } }
end
Jump to Line
Something went wrong with that request. Please try again.