From: Charles Oliver Nutter Date: 2010-07-22T14:39:23+09:00 Subject: Re: Count occurences of vars in array On Tue, Jul 20, 2010 at 8:32 AM, Colin Bartlett wrote: > jruby 1.5.0.RC1 (ruby 1.8.7 patchlevel 249) (2010-04-14 0b08bc7) >  (Java HotSpot(TM) Client VM 1.6.0_14) [x86-java] > owtdi      1.980000   0.000000   1.980000 (  1.979000) > tmtowtdi   1.523000   0.000000   1.523000 (  1.522000) > I ought to point out that in a subsequent JRuby run >  owtdi user = 1.625 and tmtowtdi user = 1.809, >  and in another run owtdi user = 2.118 and tmtowtdi user = 1.987, > so quite variable! But there was quite a lot of apparently random and > purposeless disk i/o going on while the benchmarks were running. (Thank you, > Windows Vista!) So I would place even less reliance than usual on these > benchmarks. But using inject does seem significantly slower, especially so > using 1.8.6. I know this isn't what the original post was about...but... The variability is probably due partially to the jitting behavior of the JVM; it's hard to know when the JVM will hit its stable state. FWIW, a longer run will get even faster, and passing --server to JRuby boosts it too: jruby Java 6 server, fifth iteration: user system total real owtdi 0.223000 0.000000 0.223000 ( 0.223000) tmtowtdi 0.223000 0.000000 0.223000 ( 0.223000) ruby 1.9.2 trunkish: user system total real owtdi 0.470000 0.010000 0.480000 ( 0.481433) tmtowtdi 0.350000 0.000000 0.350000 ( 0.350423) I don't have an explanation for the performance difference; the logic involved should be pretty native-lib heavy. - Charlie