This directory contains a collection of various benchmarks that have been added to the Rhino project over the years. They have all been collected here and run using the JMH framework.
To run all the benchmarks that exist, simply run, from the top-level directory:
./gradlew jmh
In addition, the environment variable BENCHMARK may be used to restrict which benchmarks are run -- it is a regular expression that matches the names of the benchmarks.
For example, to run only the SunSpider and V8 benchmarks, you can run:
BENCHMARK=V8|SunSpider ./gradlew jmh
Running all the benchmarks takes about half an hour, so this is a valuable thing to do!
If you want to run benchmarks in one mode (Interpreter or Compiler) then that can be done using the EVALMODE environment variable. For example:
EVALMODE=Compiler BENCHMARK=V8 ./gradlew jmh
will run all the V8 benchmarks, but only in compiled mode.
Java, with its just-in-time compilation pipeline, bytecode generation in Rhino, and Java's super-complex garbage collector, is sensitive to warm up time and as a result, Rhino has more variation between runs than other JavaScript engines. To get a repeatable result, we use the JMH framework, which runs each benchmark many times and does other “black hole” protection operations to try and get an accurate result. For this reason, these benchmarks take a lot longer to run than your favorite on-line JavaScript benchmarking web site.
The purpose of these benchmarks has historically been to make Rhino perform better in server-side environments, so they all run at the maximum optimization level (9). Since so many people also use Rhino in interpreted mode, if there's an interest in benchmarking that too then we can always adjust these tests.
Here are a few notes on the specific benchmarks: