javax.script interface to Rhino 10x slower than using Rhino direct?

Skip to first unread message

Paul C. Bryan

Jun 11, 2010, 9:34:04 PM6/11/10
Excuse me if this question has been asked before.

I performed a simple benchmark with interpreted and pre-compiled
scripts in Rhino, using the Rhino API (1.7R2) and using javax.script
(Java SE 6b18), evaluating a simple arithmetic expression "1+1". I
was expecting similar performance between the two. I was surprised to
see that javax.script calls to a simple eval() call were taking an
order of magnitude longer than evaluating the same expression using
the Rhino API direct (pre-compiled vs. pre-compiled).

So, would this be expected or is it more likely I've done something
horribly wrong in my calls through javax.script? Perhaps the version
of Rhino that ships w. the JRE is older and slower?

Thanks in advance.


Dan Howard

Jun 17, 2010, 8:03:28 PM6/17/10
Hi Paul,

Check this blog post out.

He did some bench testing with some solutions.

Paul C. Bryan

Jun 18, 2010, 11:11:37 AM6/18/10
On Jun 17, 5:03 pm, Dan Howard <> wrote:

Thanks for pointing me to this. I made sure in my testing that I was
reusing the script engine. I can only imagine how much slower it would
be if I did otherwise. Based on my testing, I've concluded that if
performance is critical—and it is in my case—the Rhino API should used
directly rather than using javax.script.


Reply all
Reply to author
0 new messages