GraalVM demos: Simple Java stream benchmark

This application is a small benchmark of the Java stream API.

Prerequisites

Preparation

Download or clone the repository and navigate into the java-simple-stream-benchmark directory:

  1. git clone https://github.com/graalvm/graalvm-demos
  2. cd graalvm-demos/java-simple-stream-benchmark

Build the benchmark. You can manually execute mvn package, but there is alsoa build.sh script included for your convenience.

  1. ./build.sh

Now you are all set to execute the benchmark and compare the results between different JVMs.

Export the GraalVM home directory as the $GRAALVM_HOME and add $GRAALVM_HOME/binto the path, using a command-line shell for Linux:

  1. export GRAALVM_HOME=/path/to/graalvm

and for macOS:

  1. export GRAALVM_HOME=/path/to/graalvm/Contents/Home

Running the benchmark

To run the benchmark, you need to execute the target/benchmarks.jar file.You can run it with the following command:

  1. $GRAALVM_HOME/bin/java -jar target/benchmarks.jar

If you would like to run the benchmark on a different JVM, you can run it withwhatever java you have. However, if you just want to run it on the same JVM,but without the GraalVM compiler, you may add the -XX:-UseJVMCICompiler optioninto the same command.

  1. $GRAALVM_HOME/bin/java -XX:-UseJVMCICompiler -jar target/benchmarks.jar

This way, the GraalVM compiler will not be used as the JVMCI compiler and the JVM will use its default one.

A note about the results

The benchmark mode is AverageTime in nanoseconds per operation,which means lower numbers are better.

Note that the results you see can be influenced by the hardware you are runningthis benchmark on, the CPU load, and other factors. Interpret them responsibly.