Revision 31bdcdbc764ddc63dee6a1a6290f00a46167fe8e authored by jekyllbot on 21 March 2018, 23:10:07 UTC, committed by jekyllbot on 21 March 2018, 23:10:07 UTC
1 parent 33f59ae
Raw File
string-replacement
#!/usr/bin/env ruby
require 'benchmark/ips'

def str
  'http://baruco.org/2014/some-talk-with-some-amount-of-value'
end

Benchmark.ips do |x|
  x.report('#tr')    { str.tr('some', 'a')    }
  x.report('#gsub')  { str.gsub('some', 'a')  }
  x.report('#gsub!') { str.gsub!('some', 'a') }
  x.report('#sub')   { str.sub('some', 'a')   }
  x.report('#sub!')  { str.sub!('some', 'a')  }
end
back to top