[MacRuby-devel] [MacRuby] #424: performance regression from ruby 1.8 and 1.9

MacRuby ruby-noreply at macosforge.org
Sat Nov 28 13:49:55 PST 2009


#424: performance regression from ruby 1.8 and 1.9
-------------------------------------+--------------------------------------
 Reporter:  jordan.breeding@…        |       Owner:  lsansonetti@…        
     Type:  defect                   |      Status:  new                  
 Priority:  blocker                  |   Milestone:                       
Component:  MacRuby                  |    Keywords:                       
-------------------------------------+--------------------------------------

Comment(by jordan.breeding@…):

 Alright, after taking another look I don't know that this is the only
 place where it is slower, but String is definitely causing some of the
 problem. I add a method to String to swap characters inside the String,
 this seems to be consistently slower in MacRuby.

 {{{
 #!/usr/bin/eval ruby

 class String
     def swap(first, second)
         self.dup.swap!(first, second)
     end

     def swap!(first, second)
         temp_store = self[first]
         self[first] = self[second]
         self[second] = temp_store
         return self
     end
 end

 # first test
 puts
 puts("Test 001 -- String character swap, 2500000 times")

 $staticString = "asdfghjkl;123456789"
 $firstTime = 0.0
 2500000.times {
     randOne = rand($staticString.length)
     randTwo = rand($staticString.length)
     innerTime = Time.new
     newString = $staticString.swap(randOne, randTwo)
     $firstTime += Time.new - innerTime
 }

 puts("Test 001: %.4f seconds" % [$firstTime])
 puts

 }}}

 {{{
 63 jordan at thetourist ~/Tests/performance > ruby
 ./small_performance_test.rb

 Test 001 -- String character swap, 2500000 times
 Test 001: 7.8250 seconds

 64 jordan at thetourist ~/Tests/performance > /opt/homebrew/bin/ruby
 ./small_performance_test.rb

 Test 001 -- String character swap, 2500000 times
 Test 001: 7.3780 seconds

 65 jordan at thetourist ~/Tests/performance > macruby
 ./small_performance_test.rb

 Test 001 -- String character swap, 2500000 times
 Test 001: 23.7841 seconds

 }}}

-- 
Ticket URL: <http://www.macruby.org/trac/ticket/424#comment:11>
MacRuby <http://macruby.org/>



More information about the MacRuby-devel mailing list