I've used Rhino for a scripting component inside graphics. In the project there are about 200 small scripts running independantly. Immediately when starting the application the scripts should be at full speed. Rhino's performance was sufficient, but since Oracle advices to migrate to Nashorn, i'm facing a dilema.
Below a picture showing the load difference between Rhino and Nashorn at approximayely 15,000 invocations of the scripts. The Startup slowness of Nashorn is my biggest issue.
Note, this was back on JDK 1.8.0. JDK 1.8u5 is similar
I hope the picture is clear.
This is an outline of how i use the ScriptEngine:
- I'm using One scripting Engine instance,
- i create a CompiledScript object for each script,
- A Swingworker executes a CompiledScript.eval() once.
- Every half second the SwingWorkers are started.
- Each CompiledScript has its own SimpleScriptContext instance which is reused for every execution.
Below i included a runtime profile of how busy the engine is over time;
Does anyone know how to overcome the startup slowness of Nashorn?
UPDATE 15 April '15
Ran the same test with 200 seperate scripts on Java8u45.
Performance is much better! Runs similarly fast as Rhino on Java7.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…