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
Search Repo:
Michael S. Klishin (author)
Fri May 16 16:44:20 -0700 2008
commit  24331d46eb02ccf3c7fa658a74e58dbd6cd4c1ad
tree    b98b4e2d28102783831bdea656cbeb2b840db954
parent  c53276953f5ad83c328c0efebadfd599ef6f91a4
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)