dniq
February 15, 2012, 9:57am
41
On Fri, Feb 3, 2012 at 12:56 PM, Dmitry N. [email protected]
wrote:
jruby is just as slow as regular ruby 1.9.3.
I cannot reproduce. Post your jruby -v…I suspect it’s running with
the non-optimizing JVM mode.
This is JRuby master + Java 7, which is the fastest of all Ruby impls
I have installed:
system ~/projects/jruby $ jruby -rbenchmark -e “3.times { puts
Benchmark.measure { for a in 0…1E8; a * 2; end } }”
8.945000 0.000000 8.945000 ( 8.945000)
8.405000 0.000000 8.405000 ( 8.405000)
8.341000 0.000000 8.341000 ( 8.341000)
system ~/projects/jruby $ rvm 1.9.3 do ruby -rbenchmark -e “3.times {
puts Benchmark.measure { for a in 0…1E8; a * 2; end } }”
17.540000 0.000000 17.540000 ( 17.552517)
17.440000 0.010000 17.450000 ( 17.440687)
17.490000 0.000000 17.490000 ( 17.498955)
system ~/projects/jruby $ macruby -rbenchmark -e “3.times { puts
Benchmark.measure { for a in 0…1E8; a * 2; end } }” 15.800000
0.010000 15.810000 ( 15.803463)
15.750000 0.000000 15.750000 ( 15.751863)
15.850000 0.000000 15.850000 ( 15.860579)
system ~/projects/jruby $ …/rubinius/bin/rbx -rbenchmark -e “3.times
{ puts Benchmark.measure { for a in 0…1E8; a * 2; end } }”
11.190136 0.002077 11.192213 ( 11.193023)
11.087971 0.003063 11.091034 ( 11.091239)
7.020758 0.001578 7.022336 ( 7.022235)
It’s a pretty meaningless benchmark, though.
dniq
February 15, 2012, 10:05am
42
And your other bench. Again, pretty meaningless.
MacRuby does especially poorly here.
system ~/projects/jruby $ cat other_bench.rb
s = “This is a test string”
re = Regexp.new( / test / )
5.times {
puts Benchmark.measure {
for a in 0…1E7
re.match( s )
end
}
}
system ~/projects/jruby $ jruby -rbenchmark other_bench.rb
3.088000 0.000000 3.088000 ( 3.088000)
2.359000 0.000000 2.359000 ( 2.359000)
2.412000 0.000000 2.412000 ( 2.412000)
system ~/projects/jruby $ rvm 1.9.3 do ruby -rbenchmark other_bench.rb
12.880000 0.010000 12.890000 ( 12.894050)
12.840000 0.000000 12.840000 ( 12.845842)
12.800000 0.010000 12.810000 ( 12.804021)
system ~/projects/jruby $ macruby -rbenchmark other_bench.rb
65.710000 2.300000 68.010000 ( 56.906346)
^C
system ~/projects/jruby $ …/rubinius/bin/rbx -rbenchmark other_bench.rb
4.682926 0.003170 4.686096 ( 4.686355)
4.719460 0.002050 4.721510 ( 4.721482)
4.181200 0.001947 4.183147 ( 4.183126)
dniq
February 3, 2012, 8:02pm
43
On Feb 3, 2012, at 12:56 PM, Dmitry N. wrote:
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