Hi list,
I'm using Nashorn via ScriptEngineManager, which constructs me a ScriptEngine 
with an ENGINE_SCOPE Bindings of type 
jdk.nashorn.api.scripting.ScriptObjectMirror.
I put an 100 million random 0 to 1000, int array into that context and iterate 
it in a loop in JS, which takes 3700ms.
var filter = 0;var i = ints.length;while(i--) {    if (+ints[i] > 500) {        
filter++;    }}
If I set my own bindings though, via ScriptEngine.setBindings():
Bindings b = new SimpleBindings();b.put("ints", ints);engine.setBindings(b, 
ScriptContext.ENGINE_SCOPE);
The exact same piece of JS code now takes 8600ms to execute. Twice as long. And 
SimpleBindings is pretty simple, just a delegation to HashMap.
Is there some trick I'm missing?
Thanks for the help!
Rod



                                          

Reply via email to