Files
jekyll/benchmark/string-replacement
Mads Ohm Larsen 60da4ef010 Fix weird spacing
2015-01-15 22:04:00 +01:00

14 lines
366 B
Plaintext

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