From: 7stud -- Date: 2008-06-01T06:11:39+09:00 Subject: Re: splitting help needed 7stud -- wrote: > > And this test shows that split() is 13% faster with a regex: > > require 'benchmark' > include Benchmark > > L_COUNT = 1_000_000 > > bm(25) do |test| > test.report("split:") do > L_COUNT.times do |i| > str = "hello|world|goodbye" > arr = str.split("|") > end > end > > test.report("regex:") do > L_COUNT.times do |i| > str = "hello|world|goodbye" > arr = str.split(/\|/) > end > end > end > Whoops. Here are the results: user system total real split: 4.620000 0.030000 4.650000 ( 4.661699) regex: 4.000000 0.030000 4.030000 ( 4.056688) -- Posted via http://www.ruby-forum.com/.