CompiledScript slower when eval with binding ?

Jim Laskey (Oracle) james.laskey at oracle.com
Thu Apr 24 11:45:52 UTC 2014


GAO,

I launched an investigation.  You can monitor by following https://bugs.openjdk.java.net/browse/JDK-8041697 .

Cheers,

-- Jim


On Apr 23, 2014, at 3:40 AM, 高寒 <ggmmaallee at gmail.com> wrote:

> Dears
> 
> I found if the script is evaled with binding, the execution time increased
> a lot.
> Do you know the reason?
> Check this
> 
> String script_text = "var a = 1";
> 
>        ScriptEngineManager manager = new ScriptEngineManager();
>        ScriptEngine engine = manager.getEngineByName("js");
>        CompiledScript script = ((Compilable) engine).compile(script_text);
> 
>        Bindings bindings = engine.createBindings();
> 
>        long dt = new Date().getTime();
>        for (int i = 0; i < 100000; i++) {
>            script.eval();
>            //script.eval(bindings); // switch to this line and feel the
> slow speed,
>        }
>        System.out.println(new Date().getTime() - dt);
> 
> -- 
> Best wishes
>      GAO



More information about the nashorn-dev mailing list