Skip to content

Instantly share code, notes, and snippets.

@coudy
Created April 3, 2014 16:43
Show Gist options
  • Save coudy/9958130 to your computer and use it in GitHub Desktop.
Save coudy/9958130 to your computer and use it in GitHub Desktop.
Runs Google's Octane Benchmark using JDK8's Nashorn engine
package eu.coudy.nashorn;
import jdk.nashorn.api.scripting.NashornScriptEngine;
import javax.script.CompiledScript;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
// svn checkout http://octane-benchmark.googlecode.com/svn/trunk/ octane-benchmark
// ...and run in the octane-benchmark directory
public class OctaneBenchmarkNashorn {
public static void main(String[] args) {
NashornScriptEngine nashorn = (NashornScriptEngine) new ScriptEngineManager()
.getEngineByName("nashorn");
try {
CompiledScript scr = nashorn.compile(new String(Files.readAllBytes(
Paths.get("run.js"))));
scr.eval();
} catch (ScriptException | IOException e) {
e.printStackTrace();
}
}
}
@mblandfo
Copy link

Remove the line "package eu.coudy.nashorn;" or else you'll get Error: Could not find or load main class OctaneBenchmarkNashorn

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment