graalvm / graal-js-jdk11-maven-demo

An example project how to run Graal/JavaScript on JDK 11 with Graal as optimizing JIT compiler for best performance.
Universal Permissive License v1.0
177 stars 63 forks source link
graal graalvm graalvm-demos javascript

Running Graal.js on stock JDK11

This is a simple maven project that demonstrates how it's possible to run Graal.js on a stock JDK11. The application is a simple JavaScript benchmark embedded in a Java application which compares performance of Graal.js and Nashorn.

Pre requirements

Setup

Execution

This project provides two execution setups (using the exec-maven-plugin). One uses the Graal compiler to JIT compile JavaScript for better performance, and the other does not and only interprets the JavaScript code. Both executions output benchmark results for Graal.js (via the GraalVM Polyglot API and the Java Scripting API) and Nashorn.

To Execute with Graal run

mvn exec:exec

To Execute without Graal run

mvn exec:exec@nograal

The benchmark prints the time per iteration in milliseconds, so lower values are better.

Running on GraalVM

This project is also setup to run on GraalVM. The setup is the same except that your JAVA_HOME should point to a directory contain GraalVM. In this case, execution without Graal is not supported.