2026-04-05 14:31:17 +00:00
|
|
|
package com.benchmark.runner;
|
|
|
|
|
|
|
|
|
|
import com.benchmark.benchmarks.DataAccessBenchmark;
|
2026-04-05 14:58:49 +00:00
|
|
|
import org.openjdk.jmh.runner.options.CommandLineOptions;
|
2026-04-05 14:31:17 +00:00
|
|
|
import org.openjdk.jmh.runner.Runner;
|
2026-04-05 14:58:49 +00:00
|
|
|
import org.openjdk.jmh.runner.options.ChainedOptionsBuilder;
|
2026-04-05 14:31:17 +00:00
|
|
|
import org.openjdk.jmh.runner.options.Options;
|
|
|
|
|
import org.openjdk.jmh.runner.options.OptionsBuilder;
|
|
|
|
|
|
|
|
|
|
public class BenchmarkMain {
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) throws Exception {
|
2026-04-05 14:58:49 +00:00
|
|
|
if (isJmhListingOrHelpCommand(args)) {
|
|
|
|
|
org.openjdk.jmh.Main.main(args);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CommandLineOptions commandLineOptions = new CommandLineOptions(args);
|
|
|
|
|
|
|
|
|
|
ChainedOptionsBuilder builder = new OptionsBuilder()
|
|
|
|
|
.parent(commandLineOptions)
|
|
|
|
|
.jvmArgsPrepend(
|
|
|
|
|
"--enable-native-access=ALL-UNNAMED",
|
|
|
|
|
"--sun-misc-unsafe-memory-access=allow",
|
|
|
|
|
"--add-opens=java.base/java.lang=ALL-UNNAMED",
|
|
|
|
|
"--add-opens=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
|
|
|
|
|
"--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
|
|
|
|
|
"--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED",
|
|
|
|
|
"--add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
|
|
|
|
|
"--add-opens=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED",
|
|
|
|
|
"--add-opens=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED",
|
|
|
|
|
"--add-opens=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED",
|
|
|
|
|
"--add-opens=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED",
|
|
|
|
|
"--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
|
|
|
|
|
"--add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
|
|
|
|
|
"--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
|
|
|
|
|
"--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
|
|
|
|
|
"--add-exports=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED",
|
|
|
|
|
"--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
|
|
|
|
|
"--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED",
|
|
|
|
|
"--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED",
|
|
|
|
|
"--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED",
|
|
|
|
|
"--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED",
|
|
|
|
|
"--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
|
|
|
|
|
"--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED"
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (args.length == 0) {
|
|
|
|
|
builder.include(DataAccessBenchmark.class.getSimpleName());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Options opt = builder.build();
|
2026-04-05 14:31:17 +00:00
|
|
|
new Runner(opt).run();
|
|
|
|
|
}
|
2026-04-05 14:58:49 +00:00
|
|
|
|
|
|
|
|
private static boolean isJmhListingOrHelpCommand(String[] args) {
|
|
|
|
|
for (String arg : args) {
|
|
|
|
|
if ("-l".equals(arg) || "-lp".equals(arg) || "-lprof".equals(arg)
|
|
|
|
|
|| "-h".equals(arg) || "--help".equals(arg)) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2026-04-05 14:31:17 +00:00
|
|
|
}
|