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

764 views
Skip to first unread message

Paul C. Bryan

unread,
Jun 11, 2010, 9:34:04 PM6/11/10
to
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.

Paul

Dan Howard

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

Check this blog post out.

http://www.jroller.com/greeneyed/entry/don_t_throw_your_scriptengines

He did some bench testing with some solutions.

Paul C. Bryan

unread,
Jun 18, 2010, 11:11:37 AM6/18/10
to
On Jun 17, 5:03 pm, Dan Howard <spro...@videotron.ca> 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.

Paul

Reply all
Reply to author
Forward
0 new messages