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

com.undefinedlabs.scope.rules.extractor.ScopeBenchmarkStatisticsExtractorResolver 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 java.util.HashMap;
import java.util.Map;
import org.openjdk.jmh.annotations.Mode;

public enum ScopeBenchmarkStatisticsExtractorResolver {
  INSTANCE;

  private final Map extractorByBenchmarkMode;

  ScopeBenchmarkStatisticsExtractorResolver() {
    this.extractorByBenchmarkMode = new HashMap<>();
    this.extractorByBenchmarkMode.put(
        Mode.SingleShotTime.shortLabel(), TimePerOpScopeBenchmarkStatisticsExtractor.INSTANCE);
    this.extractorByBenchmarkMode.put(
        Mode.SampleTime.shortLabel(), TimePerOpScopeBenchmarkStatisticsExtractor.INSTANCE);
    this.extractorByBenchmarkMode.put(
        Mode.AverageTime.shortLabel(), TimePerOpScopeBenchmarkStatisticsExtractor.INSTANCE);
    this.extractorByBenchmarkMode.put(
        Mode.Throughput.shortLabel(), OpsPerTimeScopeBenchmarkStatisticsExtractor.INSTANCE);
  }

  public ScopeBenchmarkStatisticsExtractor resolve(final Mode mode) {
    if (mode == null) {
      return NoopScopeBenchmarkStatisticsExtractor.INSTANCE;
    }

    return this.extractorByBenchmarkMode.get(mode.shortLabel()) != null
        ? this.extractorByBenchmarkMode.get(mode.shortLabel())
        : NoopScopeBenchmarkStatisticsExtractor.INSTANCE;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy