Search in sources :

Example 1 with BenchmarkResult

use of org.openjdk.jmh.results.BenchmarkResult in project deephaven-core by deephaven.

the class CsvResultWriter method recordResults.

public static void recordResults(final Collection<RunResult> results, final File file) {
    if (results.isEmpty()) {
        return;
    }
    final CsvWriter writer = new CsvWriter(file, new CsvWriterSettings());
    final Set<String> headers = new LinkedHashSet<>();
    headers.add("Benchmark");
    headers.add("Run");
    headers.add("Iteration");
    headers.add("Score");
    for (final RunResult runResult : results) {
        final BenchmarkParams runParams = runResult.getParams();
        headers.addAll(runParams.getParamsKeys());
    }
    writer.writeHeaders(headers);
    final DecimalFormat decimalFormat = new DecimalFormat("#0.000");
    int runNo = 0;
    for (final RunResult runResult : results) {
        final BenchmarkParams runParams = runResult.getParams();
        for (final BenchmarkResult benchResult : runResult.getBenchmarkResults()) {
            runNo++;
            int itNo = 0;
            for (final IterationResult itResult : benchResult.getIterationResults()) {
                itNo++;
                final Map<String, String> values = new HashMap<>();
                values.put("Benchmark", runParams.getBenchmark());
                for (String key : runParams.getParamsKeys()) {
                    values.put(key, runParams.getParam(key));
                }
                values.put("Score", decimalFormat.format(itResult.getPrimaryResult().getScore()));
                values.put("Run", Integer.toString(runNo));
                values.put("Iteration", Integer.toString(itNo));
                writer.writeRow(headers.stream().map(values::get).collect(Collectors.toList()));
            }
        }
    }
    writer.close();
}
Also used : CsvWriter(com.univocity.parsers.csv.CsvWriter) DecimalFormat(java.text.DecimalFormat) CsvWriterSettings(com.univocity.parsers.csv.CsvWriterSettings) BenchmarkResult(org.openjdk.jmh.results.BenchmarkResult) IterationResult(org.openjdk.jmh.results.IterationResult) RunResult(org.openjdk.jmh.results.RunResult) BenchmarkParams(org.openjdk.jmh.infra.BenchmarkParams)

Example 2 with BenchmarkResult

use of org.openjdk.jmh.results.BenchmarkResult in project deephaven-core by deephaven.

the class BenchmarkRunner method recordResults.

private static void recordResults(Collection<RunResult> results) {
    if (results.isEmpty()) {
        return;
    }
    // Write an in mem table, load the per iteration tables, nj them, write to disk
    final TableBuilder builder = new TableBuilder(RESULT_TABLE_DEF);
    int runNo = 0;
    for (final RunResult runResult : results) {
        final BenchmarkParams runParams = runResult.getParams();
        final String paramString = BenchmarkTools.buildParameterString(runParams);
        final String benchmarkName = BenchmarkTools.getStrippedBenchmarkName(runParams);
        final String modeString = BenchmarkTools.getModeString(runParams);
        for (final BenchmarkResult benchResult : runResult.getBenchmarkResults()) {
            int itNo = 0;
            for (final IterationResult itResult : benchResult.getIterationResults()) {
                builder.addRow(benchmarkName, modeString, itNo++, paramString, runNo, filterDouble(itResult.getPrimaryResult().getScore()), (long) (itResult.getSecondaryResults().get("Max heap").getScore()), (long) (itResult.getSecondaryResults().get("Max free heap").getScore()), (long) (itResult.getSecondaryResults().get("Max used heap").getScore()), (long) (itResult.getSecondaryResults().get("Max threads").getScore()), filterDouble(itResult.getSecondaryResults().get("Max CPU").getScore()));
            }
            runNo++;
        }
    }
    final Table topLevel = builder.build();
    final Table mergedDetails = getMergedDetails();
    final Table result = topLevel.naturalJoin(mergedDetails, "Benchmark,Mode,Run,Iteration,Params");
    final Path outputPath = Paths.get(BenchmarkTools.getLogPath()).resolve("Benchmark" + ParquetTableWriter.PARQUET_FILE_EXTENSION);
    ParquetTools.writeTable(result, outputPath.toFile(), result.getDefinition());
}
Also used : Path(java.nio.file.Path) Table(io.deephaven.engine.table.Table) BenchmarkResult(org.openjdk.jmh.results.BenchmarkResult) IterationResult(org.openjdk.jmh.results.IterationResult) TableBuilder(io.deephaven.engine.table.impl.util.TableBuilder) RunResult(org.openjdk.jmh.results.RunResult) BenchmarkParams(org.openjdk.jmh.infra.BenchmarkParams)

Example 3 with BenchmarkResult

use of org.openjdk.jmh.results.BenchmarkResult in project infinispan by infinispan.

the class BenchmarkOutputFormat method endBenchmark.

@Override
public void endBenchmark(BenchmarkResult result) {
    out.writeln("");
    if (result != null) {
        {
            Result r = result.getPrimaryResult();
            String s = r.extendedInfo();
            if (!s.trim().isEmpty()) {
                out.writeln("Result \"" + result.getParams().getBenchmark() + "\":");
                out.writeln(s);
            }
        }
        for (Result r : result.getSecondaryResults().values()) {
            String s = r.extendedInfo();
            if (!s.trim().isEmpty()) {
                out.writeln("Secondary result \"" + result.getParams().getBenchmark() + ":" + r.getLabel() + "\":");
                out.writeln(s);
            }
        }
        out.writeln("");
    }
}
Also used : RunResult(org.openjdk.jmh.results.RunResult) BenchmarkResult(org.openjdk.jmh.results.BenchmarkResult) IterationResult(org.openjdk.jmh.results.IterationResult) Result(org.openjdk.jmh.results.Result)

Aggregations

BenchmarkResult (org.openjdk.jmh.results.BenchmarkResult)3 IterationResult (org.openjdk.jmh.results.IterationResult)3 RunResult (org.openjdk.jmh.results.RunResult)3 BenchmarkParams (org.openjdk.jmh.infra.BenchmarkParams)2 CsvWriter (com.univocity.parsers.csv.CsvWriter)1 CsvWriterSettings (com.univocity.parsers.csv.CsvWriterSettings)1 Table (io.deephaven.engine.table.Table)1 TableBuilder (io.deephaven.engine.table.impl.util.TableBuilder)1 Path (java.nio.file.Path)1 DecimalFormat (java.text.DecimalFormat)1 Result (org.openjdk.jmh.results.Result)1