------art_9287_9271001.1231527693240
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

I was just doing that. :-)

require 'benchmark'

n  _000_000

Benchmark.bm(10) do |x|
 x.report("gsub") { n.times do
     "This     is  a test   string.".gsub(/ +/, ' ')
   end
 }
 x.report("gsub!") { n.times do
     "This     is  a test   string.".gsub!(/ +/, ' ')
   end
 }
 x.report("split.join") { n.times do
     "This     is  a test   string.".split.join(' ')
   end
 }
 x.report("squeeze.strip") { n.times do
     "This     is  a test   string.".squeeze(' ').strip
   end
 }
end

                user     system      total        real
gsub        4.470000   0.040000   4.510000 (  4.578173)
gsub!       4.390000   0.020000   4.410000 (  4.468695)
split.join  3.500000   0.020000   3.520000 (  3.556669)
squeeze.strip  1.980000   0.010000   1.990000 (  2.003622)

Regards,
Craig

------art_9287_9271001.1231527693240--