[MacRuby] #1019: String#gsub performance

MacRuby ruby-noreply at macosforge.org
Thu Dec 2 21:24:32 PST 2010


#1019: String#gsub performance
----------------------------------+-----------------------------------------
 Reporter:  yasuimao@…            |       Owner:  lsansonetti@…        
     Type:  defect                |      Status:  new                  
 Priority:  major                 |   Milestone:                       
Component:  MacRuby               |    Keywords:                       
----------------------------------+-----------------------------------------
 String#gsub with block performance improved dramatically with r4964, but
 String#gsub with or without block is still about 4-5 times slower than
 that of Ruby 1.8.7.

 Test 1 - gsub

 {{{
 10.times do
   text = File.read("test.txt")
   text.gsub!(/\w+/,"test")
 end
 }}}

 Test 2 - gsub with block

 {{{
 10.times do
   text = File.read("test.txt")
   text.gsub!(/\w+/){|x| x.upcase}
 end
 }}}


 The original text is in English with 8154 words.

 Results - Test 1 (sec.)

 {{{
 Ruby 1.8.7              0.126   0.144   0.136
 MacRuby 0.8 nightly     0.760   0.830   0.855
 }}}

 Results - Test 2 (sec.)

 {{{
 Ruby 1.8.7              0.369   0.336   0.303
 MacRuby 0.8 nightly     1.377   1.552   1.465
 }}}

-- 
Ticket URL: <http://www.macruby.org/trac/ticket/1019>
MacRuby <http://macruby.org/>



More information about the macruby-tickets mailing list