From: "Shot (Piotr Szotkowski)" Date: 2009-11-12T00:48:33+09:00 Subject: Re: Ruby Inline over two times slower under 1.9 than under 1.8? --J2SCkAp4GZ/dPZZf Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Ryan Davis: > On Nov 3, 2009, at 04:46 , Shot (Piotr Szotkowski) wrote: >> I=E2=80=99m 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 =E2=80=93 a slightly altered Corey Hoffstein=E2=80=99s e= xample=C2=B9 >> =E2=80=93 seems to be actually running its Ruby part slightly slower und= er >> 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? Hm, you might be quite right, as I=E2=80=99m seeing almost exactly the below results with my 1.8.7-p202+r22308 and 1.9.1-p243+r22308: > VERSION =3D 1.8.7-p160 > CMD =3D ~/.multiruby/install/1.8.7-p160/bin/ruby example.rb > # of iterations =3D 1000000, n =3D 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) > VERSION =3D 1.9.1-p129 > CMD =3D ~/.multiruby/install/1.9.1-p129/bin/ruby example.rb > # of iterations =3D 1000000, n =3D 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) ruby 1.8.7 (2009-09-11 patchlevel 202) [x86_64-linux] # of iterations =3D 1000000, n =3D 5 user system total real null_time 0.120000 0.000000 0.120000 ( 0.115550) c 0.800000 0.000000 0.800000 ( 0.805067) c-raw 0.820000 0.000000 0.820000 ( 0.818312) c-alias 0.820000 0.000000 0.820000 ( 0.821886) pure ruby 3.040000 0.010000 3.050000 ( 3.044264) ruby 1.9.1p243 (2009-07-16) [x86_64-linux] # of iterations =3D 1000000, n =3D 5 user system total real null_time 0.120000 0.000000 0.120000 ( 0.120553) c 0.330000 0.000000 0.330000 ( 0.335894) c-raw 0.330000 0.000000 0.330000 ( 0.322273) c-alias 0.320000 0.000000 0.320000 ( 0.324713) pure ruby 1.110000 0.000000 1.110000 ( 1.108753) # of iterations =3D 1000000, n =3D 5 I guess the lesson here is to benchmark my actual code (rather than arbitrary examples) and see what differences I=E2=80=99ll find there. :) BTW: http://zenspider.com/ZSS/Products/RubyInline/ mentions running =E2=80=98make bench=E2=80=99 to benchmark RubyInline (which doesn=E2=80=99t= work for me) and http://zenspider.com/ZSS/Products/Download.html is a bit behind with the =E2=80=98Current Version=E2=80=99 info. =E2=80=94 Shot, who=E2=80=99s off to play with RubyToC now. :) --=20 C++ (from Bjarne Stroustrup, a compatriot of DHH, and who at the time was at Bell/ATT Labs) is like H=C3=A4agen Dazs Ice Cream; you think it=E2= =80=99s from Scandanavia, but it=E2=80=99s really an industrial product from New Jersey. [Rick DeNatale on classification of languages by geographic origin, ruby-ta= lk] --J2SCkAp4GZ/dPZZf Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAkr63MsACgkQi/mCfdEo8UqNTgCgvFHY8rAU8r9u6Jgi2U54rP8c FQwAnRGLyNOuOg6Ut2W7ryL2IKSJbL/h =iwbS -----END PGP SIGNATURE----- --J2SCkAp4GZ/dPZZf--