Class MetricConversionUtil

java.lang.Object
de.cuioss.benchmarking.common.report.MetricConversionUtil

public final class MetricConversionUtil extends Object
Central utility for converting benchmark metrics between different units. This is the SINGLE source of truth for all metric conversions.
  • Method Details

    • convertToOpsPerSecond

      public static double convertToOpsPerSecond(double score, String unit)
      Converts a benchmark score to operations per second.
      Parameters:
      score - the raw score value
      unit - the unit string from JMH
      Returns:
      throughput in operations per second
    • convertToMillisecondsPerOp

      public static double convertToMillisecondsPerOp(double score, String unit)
      Converts a benchmark score to milliseconds per operation. This is the CENTRALIZED method for all latency conversions.
      Parameters:
      score - the raw score value
      unit - the unit string from JMH
      Returns:
      latency in milliseconds per operation
    • calculatePerformanceGrade

      public static String calculatePerformanceGrade(double throughput)
      Calculates a performance grade based on throughput.
      Parameters:
      throughput - operations per second
      Returns:
      performance grade string
    • formatForDisplay

      public static String formatForDisplay(double value)
      Central method for formatting numeric values for display. Rules: - Values less than 2: 2 fraction digits - Values less than 10: 1 fraction digit - Values greater than or equal to 10: No fraction digits
      Parameters:
      value - the numeric value to format
      Returns:
      formatted string representation
    • formatThroughput

      public static String formatThroughput(double value)
      Formats throughput value with appropriate units.
      Parameters:
      value - throughput in ops/s
      Returns:
      formatted string with units
    • formatLatency

      public static String formatLatency(double ms)
      Formats latency value with appropriate units.
      Parameters:
      ms - latency in milliseconds
      Returns:
      formatted string with units