require 'benchmark' Benchmark.bmbm do |x| x.report { 500000.times { a = 'foobar'[/(\Afoo)bar/] } } x.report { 500000.times { a = 'foobar'[/\A(foo)bar/] } } end
Standard input is empty
Rehearsal ------------------------------------
0.630000 0.000000 0.630000 ( 0.628344)
0.620000 0.000000 0.620000 ( 0.628949)
--------------------------- total: 1.250000sec
user system total real
0.640000 0.000000 0.640000 ( 0.635875)
0.630000 0.000000 0.630000 ( 0.627771)