Subj : Re: Performance question: Interpreter vs. CodeGen? To : Tom From : Igor Bukanov Date : Fri Jan 24 2003 01:33 pm Tom wrote: > Hi, > > By doing Context.setOptimizationLevel(-1) will force Rhino to call > Interpreter instead of CodeGen when compiling a js function. In our > app we have a compiled js function and will call it many times, based > on the number of rows returned from database query. So it's a > compile-once-run-many-times thing. I wonder if anyone could provide > some hints on the performance difference between using Interpreter vs. > CodeGen? By looking at the source code there doesn't appear to be big > difference, am I correct? We had to switch from CodeGen to > Interpreter because we found out that the java classes generated by > CodeGen don't get garbage collected by JVM. > Under mozilla/js/benchmarks in Mozilla CVS you may find few benchmarks testing pure JavaScript performance. Some of them (especially ones in mozilla/js/benchmarks/BenchPress.js, http://lxr.mozilla.org/mozilla/source/js/benchmarks/BenchPress.js ) run with optimizer under JDK 1.3-1.4 faster by the factor of 10, while in many the difference is under the factor of 1.5 - 2. On the other hand, if your scripts mostly call functions provided by the standard EcmaScript objects (Math, String, RegExp etc.) or call Java methods via LiveConnect, the difference will be negligible while with interpreter the memory usage will be lower. Regards, Igor .