From: Chuck Remes Date: 2012-02-04T04:01:38+09:00 Subject: Re: Basic Ruby performance On Feb 3, 2012, at 12:56 PM, Dmitry Nikiforov wrote: > Tried rubinius and jruby. Rubinius so far is the fastest one, but still > slower than Perl. The empty "for" loop runs about as fast as "while" or > .each (10 seconds - rubinius, 3.5 seconds - Perl), although .times > takes only 6 seconds. > > Regexp match using / test /.match works about the same as s =~ / test /, > and is about 5 seconds, vs. Perl's 1.4s (1e7 repetitions), although, > seeing as there's such a huge difference in just empty loop alone it's > hard to tell if it's because regexps themselves are slower in Ruby, or > if it's because of the regexp engine... :( > > jruby is just as slow as regular ruby 1.9.3. The thing you need to know about Rubinius and JRuby is that they both JIT (just-in-time) compile the code, but they need to collect statistics on the runtime profile first. That usually takes a few seconds. So any test that runs for under 10s or so doesn't give the runtime much opportunity to optimize the code. If you really are going to be working on big datasets, then try to benchmark something that takes at least a minute or so to run. You *cannot* reliably extrapolate performance from a test that runs 4s versus 2s. cr