public
Rubygem
Description: Merb Core: All you need. None you don't.
Homepage: http://www.merbivore.com
Clone URL: git://github.com/wycats/merb-core.git
Sun May 11 14:17:29 -0700 2008
commit  af548c0808576118ffbb43468104146feb7acbf9
tree    4b1a608fd28f0ae9a47797745d96eaf4e4b94dbb
parent  714a73910a39bdb733116dacab301c61d38edf07 parent  f8df510045587cd49a78851c1c6fc17a0e333a7d
merb-core / simple_benches / squeeze.rb
100644 13 lines (10 sloc) 0.421 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
require 'benchmark'
 
TIMES = (ARGV[0] || 100_000).to_i
 
Benchmark.bmbm do |x|
  x.report("squeeze") { TIMES.times { "abc//def//ghi//jkl".squeeze("/") }}
  x.report("gsub") { TIMES.times { "abc//def//ghi//jkl".gsub(/\/+/, "/") }}
end
 
# TIMES == 1_000_000
# user system total real
# squeeze 1.480000 0.010000 1.490000 ( 1.491509)
# gsub 3.090000 0.010000 3.100000 ( 3.107455)