bm makes the results even easier to read and provides headings for each column.
require 'benchmark' iterations = 1000000 # www. j av a2 s .c o m Benchmark.bm do |bm| bm.report("for:") do for i in 1..iterations do x = i end end bm.report("times:") do iterations.times do |i| x = i end end end
bm method allows you to collect a group of benchmark tests together and display the results in a prettier way.