Speed differences between ruby versions

Hello all,

In search of a bug, I created some sample code for a C-binding.
(Code attached, mkdir test/; cd test/; ruby extconf.rb; make; cd …;
ruby test/buggy.rb)

Turns out, @home (measured with time ruby test/buggy.rb):
1.6.5, 1.6.8, 1.7.2 (date unknown) are fast
1.6.7 slowish (10x)
1.7.3 (dec 19) slow (>30x)

and @work:
1.6.7 (I think), 1.7.2 (date unknown) fast
1.7.3 (dec 16) slow

It is all very consistent on one machine, but I can not pinpoint what
causes it… Anyone can reproduce this? Any insights?

ruby -rprofile shows the difference in speed as follows (i.e. Bla#new):

fast:
% cumulative self self total
time seconds seconds calls ms/call ms/call name
55.97 1.36 1.36 12345 0.11 0.11 Bla#new
43.62 2.42 1.06 1 1060.00 2420.00 Fixnum#times
0.00 2.42 0.00 1 0.00 0.00 Class#inherited
0.00 2.42 0.00 1 0.00 0.00 Array#allocate
0.00 2.42 0.00 12 0.00 0.00 String#allocate
0.00 2.42 0.00 1 0.00 2430.00 #toplevel
0.00 2.42 0.00 1 0.00 0.00 Kernel.require

slow:
% cumulative self self total
time seconds seconds calls ms/call ms/call name
95.09 38.34 38.34 12345 3.11 3.11 Bla#new
4.91 40.32 1.98 1 1980.00 40320.00 Integer#times
0.00 40.32 0.00 1 0.00 0.00 Array#allocate
0.00 40.32 0.00 1 0.00 40320.00 #toplevel
0.00 40.32 0.00 1 0.00 0.00 Class#inherited
0.00 40.32 0.00 4 0.00 0.00 String#allocate
0.00 40.32 0.00 1 0.00 0.00 Kernel.require

Bye,
Kero.

PS: my bug turned out to be “-ldmalloc” for gcc, that solved my memory
leak, but not the speed difference.

±-- Kero ------------------------------ kero@chello.nl —+

Don’t split your mentality without thinking twice |
Proud like a God – Guano Apes |
±-- M38c ---------- http://httpd.chello.nl/k.vangelder —+

native.c (449 Bytes)

buggy.rb (51 Bytes)

extconf.rb (41 Bytes)