File: string-replacement

package info (click to toggle)
jekyll 4.3.4%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,356 kB
  • sloc: ruby: 16,765; javascript: 1,455; sh: 214; xml: 29; makefile: 9
file content (14 lines) | stat: -rwxr-xr-x 386 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/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