Search in sources :

Example 1 with IterationResult

use of org.openjdk.jmh.results.IterationResult in project pie by metaborg.

the class PieMetricsProfiler method afterIteration.

@Override
public Collection<? extends Result> afterIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams, IterationResult result) {
    final ArrayList<Result> results = new ArrayList<>();
    if (!measurementsActive)
        return results;
    final TimeUnit targetTimeUnit = benchmarkParams.getTimeUnit();
    for (Measurement measurement : measurements) {
        results.add(measurement.createSingleShotResult("systemNanoTime", measurement.time.systemNanoTime, targetTimeUnit));
        results.add(measurement.createSingleShotResult("threadCpuTime", measurement.time.threadCpuTime, targetTimeUnit));
        results.add(measurement.createSingleShotResult("threadUserTime", measurement.time.threadUserTime, targetTimeUnit));
        if (measurement.report != null) {
            results.add(measurement.createAvgScalarResult("providedResources", measurement.report.totalProvidedResources, "resources"));
            results.add(measurement.createAvgScalarResult("requiredResources", measurement.report.totalRequiredResources, "resources"));
            results.add(measurement.createAvgScalarResult("requiredTasks", measurement.report.totalRequiredTasks, "tasks"));
            results.add(measurement.createAvgScalarResult("checkedProvidedResourceDependencies", measurement.report.totalCheckedProvidedResourceDependencyCount, "dependencies"));
            results.add(measurement.createAvgScalarResult("checkedRequiredResourceDependencies", measurement.report.totalCheckedRequiredResourceDependencyCount, "dependencies"));
            results.add(measurement.createAvgScalarResult("checkedRequiredTaskDependencies", measurement.report.totalCheckedRequiredTaskDependencyCount, "dependencies"));
            results.add(measurement.createAvgScalarResult("executedTasks", measurement.report.totalExecutionCount, "tasks"));
        }
    }
    measurementsActive = false;
    return results;
}
Also used : ArrayList(java.util.ArrayList) TimeUnit(java.util.concurrent.TimeUnit) ScalarResult(org.openjdk.jmh.results.ScalarResult) IterationResult(org.openjdk.jmh.results.IterationResult) SingleShotResult(org.openjdk.jmh.results.SingleShotResult) Result(org.openjdk.jmh.results.Result)

Example 2 with IterationResult

use of org.openjdk.jmh.results.IterationResult in project kie-benchmarks by kiegroup.

the class MemoryConsumptionProfiler method afterIteration.

@Override
public Collection<? extends Result> afterIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams, IterationResult result) {
    if (!proceedWithMetrics.get()) {
        return Collections.EMPTY_LIST;
    }
    final UsedMemory usedMemory;
    try {
        usedMemory = getUsedMemoryAfterSettling();
    } catch (IllegalStateException ex) {
        logger.error("{0} deactivated due to error during metrics recording.", getClass().getSimpleName(), ex);
        return Collections.EMPTY_LIST;
    }
    final List<Result> results = new ArrayList<>();
    final double usedHeap = bytesToKB(usedMemory.usedHeapMemory);
    final double usedNonHeap = bytesToKB(usedMemory.usedNonHeapMemory);
    final double total = bytesToKB(usedMemory.totalCommittedMemory);
    final double metaSpace = bytesToKB(usedMemory.metaSpaceMemory);
    results.add(new ScalarResult("mem.used.heap", usedHeap, "kB", AggregationPolicy.AVG));
    results.add(new ScalarResult("mem.used.nonheap", usedNonHeap, "kB", AggregationPolicy.AVG));
    results.add(new ScalarResult("mem.total", total, "kB", AggregationPolicy.AVG));
    results.add(new ScalarResult("mem.used.metaspace", metaSpace, "kB", AggregationPolicy.AVG));
    return results;
}
Also used : ArrayList(java.util.ArrayList) ScalarResult(org.openjdk.jmh.results.ScalarResult) ScalarResult(org.openjdk.jmh.results.ScalarResult) IterationResult(org.openjdk.jmh.results.IterationResult) Result(org.openjdk.jmh.results.Result)

Example 3 with IterationResult

use of org.openjdk.jmh.results.IterationResult 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 4 with IterationResult

use of org.openjdk.jmh.results.IterationResult 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 5 with IterationResult

use of org.openjdk.jmh.results.IterationResult in project aws-greengrass-nucleus by aws-greengrass.

the class MiscResultRecorderProfiler method afterIteration.

@Override
public Collection<? extends Result<?>> afterIteration(final BenchmarkParams benchmarkParams, final IterationParams iterationParams, final IterationResult result) {
    List<Result<?>> all = new ArrayList<>();
    counters.values().stream().map(e -> new ScalarResult(SECONDARY_RESULT_PREFIX + e.key, (double) e.counter.get(), e.unit, e.aggregationPolicy)).sequential().forEach(all::add);
    all.addAll(results.values());
    return all;
}
Also used : ArrayList(java.util.ArrayList) ScalarResult(org.openjdk.jmh.results.ScalarResult) ScalarResult(org.openjdk.jmh.results.ScalarResult) IterationResult(org.openjdk.jmh.results.IterationResult) Result(org.openjdk.jmh.results.Result)

Aggregations

IterationResult (org.openjdk.jmh.results.IterationResult)5 ArrayList (java.util.ArrayList)3 Result (org.openjdk.jmh.results.Result)3 ScalarResult (org.openjdk.jmh.results.ScalarResult)3 BenchmarkParams (org.openjdk.jmh.infra.BenchmarkParams)2 BenchmarkResult (org.openjdk.jmh.results.BenchmarkResult)2 RunResult (org.openjdk.jmh.results.RunResult)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 TimeUnit (java.util.concurrent.TimeUnit)1 SingleShotResult (org.openjdk.jmh.results.SingleShotResult)1