Forum: JRuby eval method seems to be slower than mri

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
C6b63e9914149409d4b007918649ae65?d=identicon&s=25 Khaled Al Habache (khelll)
on 2008-12-05 00:46
(Received via mailing list)
hi, i was trying this simple test on both ruby mri 1.8.7 and jruby 1.5
to
benchmark the different ways of dynamic method calling in ruby.
have a look on the test :

require "benchmark"   # from the Ruby Application Archive include
Benchmark
test = "Stormy Weather"
m = test.method(:length)
n = 100000
Benchmark.bmbm {|x|
  x.report("call") { n.times { m.call } }
  x.report("send") { n.times { test.send(:length) } }
  x.report("eval") { n.times { eval "test.length" } }
}


and here is my console output :

khelll@khelll-laptop:~$ ruby projects/rubytest/eval.rb
Rehearsal ----------------------------------------
call   0.040000   0.030000   0.070000 (  0.068623)
send   0.060000   0.010000   0.070000 (  0.076176)
eval   0.350000   0.050000   0.400000 (  0.392843)
------------------------------- total: 0.540000sec

           user     system      total        real
call   0.060000   0.010000   0.070000 (  0.073063)
send   0.060000   0.020000   0.080000 (  0.078077)
eval   0.370000   0.020000   0.390000 (  0.393576)
khelll@khelll-laptop:~$ jruby projects/rubytest/eval.rb
Rehearsal ----------------------------------------
call   0.076000   0.000000   0.076000 (  0.076363)
send   0.054000   0.000000   0.054000 (  0.053325)
eval   2.731000   0.000000   2.731000 (  2.731181)
------------------------------- total: 2.861000sec

           user     system      total        real
call   0.023000   0.000000   0.023000 (  0.023475)
send   0.041000   0.000000   0.041000 (  0.041561)
eval   2.646000   0.000000   2.646000 (  2.645752)
khelll@khelll-laptop:~$


What do u think?
13313ac2ec7ba7c43b1b952db034ff3b?d=identicon&s=25 Thomas E Enebo (Guest)
on 2008-12-05 01:23
(Received via mailing list)
It is fairly well know by us that eval is slower for us.  I believe we
have a bug open on this somewhere.

We will be able to make some progress on this in the future since we
are splitting off our IDE-support in the parser, but we will probably
never parse (therefore run) as fast as MRI (I should not say 'never'
:) ).

For what it is worth, Ruby1.9 is not very fast at eval either since it
needs to compile to YARV bytecode before running.

-Tom

On Thu, Dec 4, 2008 at 5:46 PM, Khaled al Habache <khellls@gmail.com>
wrote:
>   x.report("send") { n.times { test.send(:length) } }
> eval   0.350000   0.050000   0.400000 (  0.392843)
> eval   2.731000   0.000000   2.731000 (  2.731181)
>
--
Blog: http://www.bloglines.com/blog/ThomasEEnebo
Email: enebo@acm.org , tom.enebo@gmail.com

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
This topic is locked and can not be replied to.