Yoko Harada wrote:
I'm interested in what Charles said in
http://www.nabble.com/-ANN--ruby2java-0.0.1-Released-td23679153.html
about "jruby.compile.mode=FORCE." This option works in
Ruby#runNomally(Node scriptNode) method and causes compilation. So, I
implemented a feature to set this option and compared with no
compilation mode. The result was not that expected. The reason would
be that runNormally() method compile the script everytime before
evaluation. When I executed testString.rb a hundred times, the result
was:
CompileMode.OFF 2983 ms
CompileMode.JIT 21463 ms
CompileMode.FORCE 21032 ms
Yes, I would not expect compilation to do much better than JIT mode, and
if it's forced to compile every time then it would certainly be slower
than no compiling at all.
Next, I implemented a "compile-once-eval-many-times" feature. To make
this, I changed two private methods to be public, "public Script
tryCompile(Node node)" and "public IRubyObject runScript(Script
script), so that external programs can execute compilation and
evaluation individually. This time the result was:
CompileMode.OFF 2979 ms
CompileMode.JIT 2785 ms
CompileMode.FORCE 2671 ms
This was a great improvement, but the two compilation modes were still
not so fast compared with no compilation.
In general, how fast does a compiled script run compared with no
compilation mode?
It really depends what the script is doing. If it's just a simple script
that you're running many times, it may not make a difference. Are you
just precompiling the contents of testString.rb and re-running them?
Given that the bulk of the calls in that script would just be calling
String methods, I don't expect precompilation would improve things very
much.
If ruby2java makes it really fast, I want to execute ruby2java script
in Java before evaluations. In this case, the problem would be how to
get a compiled script and eval it. I want to avoid reading a compiled
script from a file. Any idea?
ruby2java currently does no compilation *at all*. The contents of the
specified scripts are actually evaluated on class load. It could
certainly precompile and run the precompiled content at startup, but it
does not at the moment.
Are you interested in this to wire up the "compiled" logic in JSR223 or
for some other specific purpose?
- Charlie
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email