Hi.
I'm relatively new to Rhino, and I've noticed that the first time a
certain JS function is executed, it's rather slow, but repeated calls
are getting faster:
(init: 162 ms)
(eval JSLint source: 370 ms)
invoke JSLINT(): 2944 ms
invoke JSLINT(): 1518 ms
invoke JSLINT(): 571 ms
invoke JSLINT(): 418 ms
invoke JSLINT(): 451 ms
invoke JSLINT(): 419 ms
invoke JSLINT(): 404 ms
invoke JSLINT(): 406 ms
invoke JSLINT(): 388 ms
invoke JSLINT(): 381 ms
This curve tells me that some kind of cache or optimization is kicking
in, and I'm wondering what it is. Is it inherent in Rhino? Is it the
JVM? Or some kind of reuse of memory structures?
AFAIK, there is no JIT compiler in Rhino, at least not in the version
included in Java 6 SE, and Sun's guide [0] says that "JavaScript-to-
bytecode compilation (also called 'optimizer')" has been excluded in
their version.
Reduced code excerpt (using the API from javax.script):
(the 'jslintSrc' String is Crockford's JSLint script [1])
engine.eval(jslintSrc);
Invocable inv = (Invocable) engine;
for (int i = 0; i < 10; ++i) {
// JSLint is linting itself, just for testing:
inv.invokeFunction("JSLINT", jslintSrc);
}
cheers,
stefan
[0]
http://java.sun.com/javase/6/docs/technotes/guides/scripting/programmer_guide/index.html#jsengine
[1] http://www.jslint.com/fulljslint.js
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino