Javascript-Rhino performance compared to TCL/JPython

10 views
Skip to first unread message

Marcel Ruff

unread,
Apr 17, 2000, 3:00:00 AM4/17/00
to
Hi,

for my project i made a *very simple* perfomance comparison
of
Jacl (=TCL interpreter implemented in Java)
JPyton (=Python interpreter implemented in Java)
Rhino (= Javascript interpreter implemented in Java)

In my case, i needed a script interpreter embeded into my
Java appplication.

If it interests you, the results are below.

best regards, Marcel

Performance comparison of TCL/Python/Javascript embedded in Java
=================================================================

IMPORTANT:
This tests *only one very simple script* (which represents our purpose).
It tests running this embedded in Java.
Linux 2.2.14, Blackdown JDK 1.2.2, 256 MB-RAM, Athlon 600MHz, April-2000


+-----------------------------------------------+
|JPython: http://www.jpython.org |
+-----------------------------------------------+

------------------------------
| result = 0 |
| if exitValue == 0: |
| result = 1 |
| else: |
| result = -1 |
------------------------------

interp.exec() -> 34 millisec (without JIT)
20 millisec (with sunwjit)
(average from 100 similar calls)

precompiled (on the fly) ->
0,09 millisec (without JIT)!
0,11 millisec (with sunwjit)

The compilation takes 14 to 32 millis (sunwjit)


+-----------------------------------------------+
|Tcl: http://dev.scriptics.com/software/java/ |
+-----------------------------------------------+

------------------------------
| set result 0 |
| if {$exitValue == 0} { |
| set result 1 |
| } else { |
| set result -1 |
| } |
------------------------------

interp.eval() -> 0.84 millisec (without JIT)
0.54 millisec (with sunwjit)

+-----------------------------------------------+
|Javascript http://www.mozilla.org/rhino/ |
+-----------------------------------------------+

------------------------------
| var result = 0 |
| if (exitValue == 0) |
| result = 1 |
| else |
| result = -1 |
------------------------------

cx.evaluateString() -> 1.77 millisec (without JIT)
1.56 millisec (with sunwjit)
With eval set to interpreter mode (-1)


precompiled -> 0.045 millisec (without JIT)
0.035 millisec (with sunwjit)
With eval set to max. compiled mode (9)
Compilation takes 8 millis.


Result:
=======

Jacl is a pure interpreter with no compilation.
- Jacl is for small scripts and low number of calls of identical
scripts
the winner.


JPython is a pure compiler with no interpreter mode.
- JPython has a compilation pass of ~ 20 millis
and produces fast code.
- This is good for bigger scripts with 'for' loops etc.
- interp.set("exitValue", Py.newInteger(2)); only takes 10 microsec
This is very fast and allows 'cheap' new settings for
precompiled scripts
- Python is a 'full blown' object oriented language with inheritance
etc.


Javascript (Rhino) has an interpreter and compiler mode.
- The interpreter mode is 3 times slower than TCL.
- Evaluating in compiled mode is ~ 4 times faster than JPython.
(averaged over 100 calls)
- Compiling a script is faster than with JPython
(Even in highest compilation mode = 9)
- Setting a variable "var exitValue=9" takes 0.67 millis (interpreter)
and 7,6 millis (compiled mode) whis is much slower than JPython
This is quite expensive, if you want to alter settings for
precompiled scripts.
Therefore use scope.put("exitValue", scope, "99");
which takes 1 microsec and is very fast!


--
Marcel Ruff
ru...@swand.lake.de
http://www.lake.de/home/lake/swand/
http://www.xmlBlaster.org

Reply all
Reply to author
Forward
0 new messages