Search in sources :

Example 11 with NashornScriptEngine

use of jdk.nashorn.api.scripting.NashornScriptEngine in project java8-tutorial by winterbe.

the class Nashorn10 method main.

public static void main(String[] args) throws ScriptException, NoSuchMethodException {
    NashornScriptEngine engine = (NashornScriptEngine) new ScriptEngineManager().getEngineByName("nashorn");
    engine.eval("load('res/nashorn10.js')");
    long t0 = System.nanoTime();
    for (int i = 0; i < 100000; i++) {
        engine.invokeFunction("testPerf");
    }
    long took = System.nanoTime() - t0;
    System.out.format("Elapsed time: %d ms", TimeUnit.NANOSECONDS.toMillis(took));
}
Also used : NashornScriptEngine(jdk.nashorn.api.scripting.NashornScriptEngine) ScriptEngineManager(javax.script.ScriptEngineManager)

Aggregations

NashornScriptEngine (jdk.nashorn.api.scripting.NashornScriptEngine)11 SimpleScriptContext (javax.script.SimpleScriptContext)7 Bindings (javax.script.Bindings)6 ScriptContext (javax.script.ScriptContext)6 SimpleBindings (javax.script.SimpleBindings)6 ScriptEngineManager (javax.script.ScriptEngineManager)3 Person (com.winterbe.java8.samples.lambda.Person)1