fork download
  1. require 'benchmark'
  2. Benchmark.bmbm do |x|
  3. x.report { 200000.times { a = 'foobar'[/(\Afoo)bar/] } }
  4. x.report { 200000.times { a = 'foobar'[/\A(foo)bar/] } }
  5. end
  6. Benchmark.bmbm do |x|
  7. x.report { 200000.times { a = 'foobar'[/foo(bar\z)/] } }
  8. x.report { 200000.times { a = 'foobar'[/foo(bar)\z/] } }
  9. end
  10. Benchmark.bmbm do |x|
  11. x.report { 200000.times { a = "foo\nbarbaz"[/foo\n(^bar)baz/] } }
  12. x.report { 200000.times { a = "foo\nbarbaz"[/foo\n^(bar)baz/] } }
  13. end
  14. Benchmark.bmbm do |x|
  15. x.report { 200000.times { a = "foobar\nbaz"[/foo(bar$)\nbaz/] } }
  16. x.report { 200000.times { a = "foobar\nbaz"[/foo(bar)$\nbaz/] } }
  17. end
  18. puts '--------------------------'
Success #stdin #stdout 4.15s 10040KB
stdin
Standard input is empty
stdout
Rehearsal ------------------------------------
   0.250000   0.000000   0.250000 (  0.250649)
   0.250000   0.000000   0.250000 (  0.251806)
--------------------------- total: 0.500000sec

       user     system      total        real
   0.240000   0.010000   0.250000 (  0.245141)
   0.250000   0.000000   0.250000 (  0.251401)
Rehearsal ------------------------------------
   0.240000   0.000000   0.240000 (  0.248729)
   0.250000   0.000000   0.250000 (  0.249781)
--------------------------- total: 0.490000sec

       user     system      total        real
   0.240000   0.000000   0.240000 (  0.244700)
   0.250000   0.000000   0.250000 (  0.253380)
Rehearsal ------------------------------------
   0.260000   0.000000   0.260000 (  0.260891)
   0.260000   0.000000   0.260000 (  0.260427)
--------------------------- total: 0.520000sec

       user     system      total        real
   0.250000   0.000000   0.250000 (  0.253841)
   0.260000   0.000000   0.260000 (  0.257732)
Rehearsal ------------------------------------
   0.280000   0.000000   0.280000 (  0.284074)
   0.260000   0.000000   0.260000 (  0.257840)
--------------------------- total: 0.540000sec

       user     system      total        real
   0.280000   0.000000   0.280000 (  0.279462)
   0.250000   0.000000   0.250000 (  0.254233)
--------------------------