Enhance benchmark result reporting by checking for expected fixture types and logging failures
This commit is contained in:
@@ -2,6 +2,7 @@ package com.benchmark.runner;
|
||||
|
||||
import com.benchmark.benchmarks.DataAccessBenchmark;
|
||||
import org.openjdk.jmh.annotations.Mode;
|
||||
import org.openjdk.jmh.annotations.Param;
|
||||
import org.openjdk.jmh.results.Result;
|
||||
import org.openjdk.jmh.results.RunResult;
|
||||
import org.openjdk.jmh.runner.options.CommandLineOptions;
|
||||
@@ -19,11 +20,14 @@ import java.nio.file.Paths;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class BenchmarkMain {
|
||||
@@ -120,6 +124,24 @@ public class BenchmarkMain {
|
||||
result.getScoreUnit()
|
||||
);
|
||||
}
|
||||
|
||||
Set<String> presentFixtures = new HashSet<>();
|
||||
for (RunResult runResult : sorted) {
|
||||
presentFixtures.add(runResult.getParams().getParam("fixtureType"));
|
||||
}
|
||||
|
||||
for (String expectedFixture : expectedFixtureTypes()) {
|
||||
if (presentFixtures.contains(expectedFixture)) {
|
||||
continue;
|
||||
}
|
||||
System.out.printf(
|
||||
"%-24s %14s %14s %s%n",
|
||||
expectedFixture,
|
||||
"FAILED",
|
||||
"-",
|
||||
"n/a"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -284,12 +306,39 @@ public class BenchmarkMain {
|
||||
.append(result.getScoreUnit())
|
||||
.append("` |\n");
|
||||
}
|
||||
|
||||
Set<String> presentFixtures = new HashSet<>();
|
||||
for (RunResult runResult : sorted) {
|
||||
presentFixtures.add(runResult.getParams().getParam("fixtureType"));
|
||||
}
|
||||
|
||||
for (String expectedFixture : expectedFixtureTypes()) {
|
||||
if (presentFixtures.contains(expectedFixture)) {
|
||||
continue;
|
||||
}
|
||||
sb.append("| - | `")
|
||||
.append(expectedFixture)
|
||||
.append("` | FAILED | - | `n/a` |\n");
|
||||
}
|
||||
sb.append("\n");
|
||||
}
|
||||
|
||||
return sb.toString().trim();
|
||||
}
|
||||
|
||||
private static List<String> expectedFixtureTypes() {
|
||||
try {
|
||||
java.lang.reflect.Field fixtureField = DataAccessBenchmark.class.getDeclaredField("fixtureType");
|
||||
Param param = fixtureField.getAnnotation(Param.class);
|
||||
if (param == null || param.value() == null || param.value().length == 0) {
|
||||
return List.of();
|
||||
}
|
||||
return Arrays.asList(param.value());
|
||||
} catch (NoSuchFieldException e) {
|
||||
return List.of();
|
||||
}
|
||||
}
|
||||
|
||||
private static String formatDouble(double value) {
|
||||
if (Double.isNaN(value)) {
|
||||
return "NaN";
|
||||
|
||||
Reference in New Issue
Block a user