Add LMDB/MapDB/DuckDB fixtures and update benchmark runner
This commit is contained in:
@@ -1,12 +1,21 @@
|
||||
package com.benchmark.runner;
|
||||
|
||||
import com.benchmark.benchmarks.DataAccessBenchmark;
|
||||
import org.openjdk.jmh.annotations.Mode;
|
||||
import org.openjdk.jmh.results.Result;
|
||||
import org.openjdk.jmh.results.RunResult;
|
||||
import org.openjdk.jmh.runner.options.CommandLineOptions;
|
||||
import org.openjdk.jmh.runner.Runner;
|
||||
import org.openjdk.jmh.runner.options.ChainedOptionsBuilder;
|
||||
import org.openjdk.jmh.runner.options.Options;
|
||||
import org.openjdk.jmh.runner.options.OptionsBuilder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class BenchmarkMain {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
@@ -23,6 +32,9 @@ public class BenchmarkMain {
|
||||
"--enable-native-access=ALL-UNNAMED",
|
||||
"--sun-misc-unsafe-memory-access=allow",
|
||||
"--add-opens=java.base/java.lang=ALL-UNNAMED",
|
||||
"--add-opens=java.base/java.nio=ALL-UNNAMED",
|
||||
"--add-opens=java.base/sun.nio.ch=ALL-UNNAMED",
|
||||
"--add-exports=java.base/sun.nio.ch=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",
|
||||
@@ -50,7 +62,46 @@ public class BenchmarkMain {
|
||||
}
|
||||
|
||||
Options opt = builder.build();
|
||||
new Runner(opt).run();
|
||||
Collection<RunResult> runResults = new Runner(opt).run();
|
||||
printSortedSummary(runResults);
|
||||
}
|
||||
|
||||
private static void printSortedSummary(Collection<RunResult> runResults) {
|
||||
if (runResults == null || runResults.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Map<Mode, List<RunResult>> byMode = new LinkedHashMap<>();
|
||||
for (RunResult runResult : runResults) {
|
||||
byMode.computeIfAbsent(runResult.getParams().getMode(), m -> new ArrayList<>()).add(runResult);
|
||||
}
|
||||
|
||||
System.out.println("\n=== Sorted summary by performance ===");
|
||||
for (Map.Entry<Mode, List<RunResult>> entry : byMode.entrySet()) {
|
||||
Mode mode = entry.getKey();
|
||||
List<RunResult> sorted = new ArrayList<>(entry.getValue());
|
||||
boolean lowerIsBetter = mode == Mode.AverageTime || mode == Mode.SampleTime || mode == Mode.SingleShotTime;
|
||||
|
||||
sorted.sort((a, b) -> {
|
||||
double scoreA = a.getPrimaryResult().getScore();
|
||||
double scoreB = b.getPrimaryResult().getScore();
|
||||
return lowerIsBetter ? Double.compare(scoreA, scoreB) : Double.compare(scoreB, scoreA);
|
||||
});
|
||||
|
||||
System.out.printf("%n[%s]%n", mode);
|
||||
System.out.printf("%-24s %14s %14s %s%n", "fixtureType", "score", "error", "unit");
|
||||
for (RunResult runResult : sorted) {
|
||||
Result<?> result = runResult.getPrimaryResult();
|
||||
String fixtureType = runResult.getParams().getParam("fixtureType");
|
||||
System.out.printf(
|
||||
"%-24s %14.3f %14.3f %s%n",
|
||||
fixtureType,
|
||||
result.getScore(),
|
||||
result.getScoreError(),
|
||||
result.getScoreUnit()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isJmhListingOrHelpCommand(String[] args) {
|
||||
|
||||
Reference in New Issue
Block a user