Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

An example project how to run Graal/JavaScript on JDK 11 with Graal as optimizing JIT compiler for best performance.

License

Notifications You must be signed in to change notification settings

graalvm/graal-js-jdk11-gradle-demo

Repository files navigation

Running GraalJS on stock JDK11

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

Pre requirements

Setup

  • Clone this repository
git clone https://github.com/graalvm/graal-js-jdk11-gradle-demo.git
  • Move to the newly cloned directory
cd graal-js-jdk11-gradle-demo
  • Make sure that JAVA_HOME is pointed at a JDK11 (you can run the benchmark with older JDKs as well, but Graal won't be used)
export JAVA_HOME=/path/to/jdk11; java -version

Execution

The project provides a custom JavaExec run task which sets up the JVM to use the Graal compiler to JIT compile JavaScript for better performance. You can turn off this behaviour by setting the system property graal to off. The execution outputs benchmark results for GraalJS (via the GraalVM Polyglot API and the Java Scripting API) and Nashorn.

To Execute with Graal, run

./gradlew run

To Execute without Graal, run

./gradlew run -Dgraal=off

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, the graal system property has no effect since Graal is always available.

About

An example project how to run Graal/JavaScript on JDK 11 with Graal as optimizing JIT compiler for best performance.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages