From 6d40d1b4330f0be6c0cb0d09db1944c56f0bd447 Mon Sep 17 00:00:00 2001 From: Greg Brail Date: Fri, 23 Aug 2024 12:14:03 -0700 Subject: [PATCH] Add a benchmark to measure Rhino startup time I'm a bit worried about changes I'm making with lambdas and how that will impact how long it will take Rhino to initialize all the standard objects, so let's create a microbenchmark for that. --- .../javascript/benchmarks/StartupBenchmark.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 benchmarks/src/jmh/java/org/mozilla/javascript/benchmarks/StartupBenchmark.java diff --git a/benchmarks/src/jmh/java/org/mozilla/javascript/benchmarks/StartupBenchmark.java b/benchmarks/src/jmh/java/org/mozilla/javascript/benchmarks/StartupBenchmark.java new file mode 100644 index 0000000000..add473e956 --- /dev/null +++ b/benchmarks/src/jmh/java/org/mozilla/javascript/benchmarks/StartupBenchmark.java @@ -0,0 +1,15 @@ +package org.mozilla.javascript.benchmarks; + +import java.util.concurrent.TimeUnit; +import org.mozilla.javascript.Context; +import org.openjdk.jmh.annotations.*; + +@OutputTimeUnit(TimeUnit.MICROSECONDS) +public class StartupBenchmark { + @Benchmark + public Object startUpRhino() { + try (Context cx = Context.enter()) { + return cx.initStandardObjects(); + } + } +}