From: Ryan Davis Date: 2009-11-04T04:27:23+09:00 Subject: Re: Ruby Inline over two times slower under 1.9 than under 1.8? On Nov 3, 2009, at 04:46 , Shot (Piotr Szotkowski) wrote: > I’m starting to dip my toes in non-Ruby coding (for performance > reasons) > and began with looking at the (simplest) choice of Ruby Inline. > > Interestingly, while my own number-crunching code seems to be > generally > three times faster in Ruby 1.9 than in Ruby 1.8, the attached script > – a slightly altered Corey Hoffstein’s example¹ – seems to be actually > running its Ruby part slightly slower under Ruby 1.9, and over two > times > slower when it comes to its C part: I'm not seeing that in a simpler case (factorial in example.rb from RubyInline). So maybe it is less method dispatch time and more ruby internals manipulation time? 505 % multiruby example.rb VERSION = 1.8.6-p368 CMD = ~/.multiruby/install/1.8.6-p368/bin/ruby example.rb # of iterations = 1000000, n = 5 user system total real null_time 0.110000 0.000000 0.110000 ( 0.111362) c 0.780000 0.010000 0.790000 ( 0.798776) c-raw 0.820000 0.000000 0.820000 ( 0.824597) c-alias 0.810000 0.000000 0.810000 ( 0.826391) pure ruby 3.120000 0.000000 3.120000 ( 3.121989) RESULT = 0 VERSION = 1.8.7-p72 CMD = ~/.multiruby/install/1.8.7-p72/bin/ruby example.rb # of iterations = 1000000, n = 5 user system total real null_time 0.140000 0.000000 0.140000 ( 0.141250) c 0.890000 0.000000 0.890000 ( 0.897377) c-raw 0.950000 0.010000 0.960000 ( 0.975901) c-alias 0.990000 0.000000 0.990000 ( 1.033289) pure ruby 3.260000 0.020000 3.280000 ( 3.331565) RESULT = 0 VERSION = 1.8.7-p160 CMD = ~/.multiruby/install/1.8.7-p160/bin/ruby example.rb # of iterations = 1000000, n = 5 user system total real null_time 0.120000 0.000000 0.120000 ( 0.119509) c 0.870000 0.000000 0.870000 ( 0.881604) c-raw 0.870000 0.000000 0.870000 ( 0.876080) c-alias 0.900000 0.010000 0.910000 ( 0.921587) pure ruby 3.330000 0.010000 3.340000 ( 3.357289) RESULT = 0 VERSION = 1.8.7-p174 CMD = ~/.multiruby/install/1.8.7-p174/bin/ruby example.rb # of iterations = 1000000, n = 5 user system total real null_time 0.120000 0.000000 0.120000 ( 0.125070) c 0.950000 0.000000 0.950000 ( 0.959735) c-raw 0.860000 0.000000 0.860000 ( 0.868117) c-alias 0.990000 0.010000 1.000000 ( 1.004241) pure ruby 3.550000 0.010000 3.560000 ( 3.589039) RESULT = 0 VERSION = 1.9.1-p129 CMD = ~/.multiruby/install/1.9.1-p129/bin/ruby example.rb # of iterations = 1000000, n = 5 user system total real null_time 0.150000 0.000000 0.150000 ( 0.148261) c 0.350000 0.010000 0.360000 ( 0.365500) c-raw 0.350000 0.000000 0.350000 ( 0.356689) c-alias 0.350000 0.000000 0.350000 ( 0.352744) pure ruby 1.090000 0.010000 1.100000 ( 1.133433) RESULT = 0 TOTAL RESULT = 0 failures out of 5 Passed: 1.9.1-p129, 1.8.7-p72, 1.8.7-p160, 1.8.6-p368, 1.8.7-p174 Failed: