From: botp Date: 2010-06-25T13:01:17+09:00 Subject: Re: Count substrings in string, scan too slow On Fri, Jun 25, 2010 at 1:16 AM, Michael Fellinger > I've just run some benchmarks with strscan, and it's at least in the > same ballpark as the other approaches, unless you're on rubinius, but > then all string processing is really slow on that anyway. > > Benchmark with strscan here: http://gist.github.com/451675 > that is not fair for strscan.. you are recreating the object inside the loop :) outside loop do: s=StringScanner.new "some string foo..." s2=s.dup inside loop do: s=s2 .... s.scan_until... best regards -botp