All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.undefinedlabs.scope.rules.extractor.TimePerOpScopeBenchmarkStatisticsExtractor Maven / Gradle / Ivy

Go to download

Scope is a APM for tests to give engineering teams unprecedented visibility into their CI process to quickly identify, troubleshoot and fix failed builds. This artifact contains the classes to instrument the Java JMH Benchmark Framework.

There is a newer version: 0.15.1-beta.2
Show newest version
package com.undefinedlabs.scope.rules.extractor;

import com.undefinedlabs.scope.rules.model.ScopeBenchmarkStatistics;
import org.openjdk.jmh.results.Result;
import org.openjdk.jmh.util.Statistics;

public class TimePerOpScopeBenchmarkStatisticsExtractor
    extends AbstractScopeBenchmarkStatisticsExtractor {

  public static final ScopeBenchmarkStatisticsExtractor INSTANCE =
      new TimePerOpScopeBenchmarkStatisticsExtractor();

  private TimePerOpScopeBenchmarkStatisticsExtractor() {}

  @Override
  public ScopeBenchmarkStatistics extract(final Result result) {
    final ScopeBenchmarkStatistics.Builder builder = newBuilder();
    final Statistics jmhStats = result.getStatistics();

    builder.withSampleCount(result.getSampleCount());
    builder.withScore(result.getScore());
    builder.withScoreConfidence(result.getScoreConfidence());
    builder.withScoreError(result.getScore());

    if (jmhStats != null) {
      builder.withMin(jmhStats.getMin());
      builder.withMean(jmhStats.getMean());
      builder.withMax(jmhStats.getMax());
      builder.withStdDev(jmhStats.getStandardDeviation());
      builder.withVariance(jmhStats.getVariance());
      builder.withP00(jmhStats.getPercentile(0));
      builder.withP50(jmhStats.getPercentile(50));
      builder.withP90(jmhStats.getPercentile(90));
      builder.withP95(jmhStats.getPercentile(95));
      builder.withP99(jmhStats.getPercentile(99));
      builder.withP100(jmhStats.getPercentile(100));
    }

    return builder.build();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy