I was curious to find out, first of all, how much slower Rhino (a pure-Java implementation of JavaScript) would be than, say, Spidermonkey (the C++ implementation in Firefox). I repeated the "numerical efficiency" test from yesterday (Euler's expansion series for pi) and got the following results:
Execution time (not speed, but time; higher values are worse) is plotted vertically. The surprising result? Firefox's C++ interpreter is not all that much faster than standalone Rhino. The Y-axis here goes from zero to 1200 milliseconds. Trials, on the X-axis, run from zero to values of 200000, 400000, 600000, 800000, and 1000000 for the terms argument to yesterday's pi() function. So in other words, it took Rhino 1212 milliseconds to calculate pi from a million terms, whereas it took Firefox/Spidermonkey 984 ms to do the same thing, making Firefox's interpreter about 20% faster. Rhino comes out looking quite good, considering it is, after all, "only Java."
A more shocking comparison emerged when I tested Rhino against Acrobat. As you may know, Adobe Acrobat comes with a JavaScript engine, presumably written in C++. I expected it to blow the doors off Rhino. Not so! Here are the results:
Astonishingly, Acrobat's interpreter was a full order of magnitude slower than Rhino, requiring 11765 milliseconds to calculate pi from a million terms (versus 1212 ms for Rhino). Why so slow? I have no idea. Perhaps someone from Adobe can comment.
Bottom line: Don't assume that because something is written in Java, it's (automatically) slow. It depends on the runtime environment and what it is, exactly, you're trying to do.
After this, my respect for Rhino only rises. (And it was high to begin with.)
You're making weird assumptions, or possibly your terminology is off. First of all, it's not the "Rhino-embedded-in-the-JRE," it's simply an older version of Rhino shipped with the JRE. It does not include many improvements that have been added by Google since then. Not sure why.
ReplyDeleteNext you seem to be confused as to the nature of Rhino. It is quite optimized, and if I'm not mistaken (but I could be wrong about this) it can generate JVM bytecode. The JVM has had 15 years of intense bytecode execution optimization; it's not surprising that it should demolish a rarely used JavaScript runtime. Who cares about Acrobat JS performance? Adobe does not care about Acrobat performance.
Your test really isn't measuring much of the JavaScript engine.
ReplyDeleteThe pi() function you have is so simple and being executed so many times, the bulk of the time will be spent handling the arithmetic and Math.sqrt() call.
Thus your only really measuring those two things, which I guess if that's all your gonna use Rhino for, you'll only be about 20% slower as you mentioned.
I'm guessing if you had a more robust set of tests, one that calls more JavaScript functions, recursive calls, etc. that you would see engines like TraceMonkey and v8 pull further away from Rhino.
One of the best articles i have read.I Like your effort and hardworking.
ReplyDeleteGrand Theft Auto 4 free Download | Counter Strike 1.6 Free Download | The Amazing Spider Man Free Download
Jual Obat Aborsi Asli | Obat Cytotec Asli | 082241083319
ReplyDeletejual obat aborsi pills cytotec asli manjur untuk menggugurkan kandungan usia 1 - 6 bulan gugur tuntas.CYTOTEC OBAT ASLI sangat efektif mengatasi TELAT DATANG BULANdan menjadikan anda gagal hamil , CYTOTEC adalah OBAT ABORSI 3 JAM BERHASIL GUGUR TUNTAS dengan kwalitas terbaik produk asli pfizer nomor 1 di dunia medis
JUAL OBAT ABORSI DI JEMBER
JUAL OBAT ABORSI DI JOMBANG
JUAL OBAT ABORSI DI KEDIRI
JUAL OBAT ABORSI DI NGASEM
JUAL OBAT ABORSI DI LAMONGAN
JUAL OBAT ABORSI DI LUMAJANG
JUAL OBAT ABORSI DI MADIUN
There are academic nursing writing help companies whose ultimate goal is to provide Help with Nursing Writing Services since they are aware most nursing essay writing service part-time students lack enough time to complete their college custom nursing assignments.
ReplyDeleteHealthcare research paper writing services are essential and it has become very popular for those seeking healthcare essay writing services since most of them seek Healthcare Assignment Writing Services.
ReplyDeleteI appreciated looking at your article. Very wonderful reveal. I would like to twit this on my followers. Many thanks!
ReplyDeleteFIU Blackboard
hyperbole in poetry
Equilibrium Calculator