Class MetricConversionUtil
java.lang.Object
de.cuioss.benchmarking.common.report.MetricConversionUtil
Central utility for converting benchmark metrics between different units.
This is the SINGLE source of truth for all metric conversions.
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringcalculatePerformanceGrade(double throughput) Calculates a performance grade based on throughput.static doubleconvertToMillisecondsPerOp(double score, String unit) Converts a benchmark score to milliseconds per operation.static doubleconvertToOpsPerSecond(double score, String unit) Converts a benchmark score to operations per second.static StringformatForDisplay(double value) Central method for formatting numeric values for display.static StringformatLatency(double ms) Formats latency value with appropriate units.static StringformatThroughput(double value) Formats throughput value with appropriate units.
-
Method Details
-
convertToOpsPerSecond
Converts a benchmark score to operations per second.- Parameters:
score- the raw score valueunit- the unit string from JMH- Returns:
- throughput in operations per second
-
convertToMillisecondsPerOp
Converts a benchmark score to milliseconds per operation. This is the CENTRALIZED method for all latency conversions.- Parameters:
score- the raw score valueunit- the unit string from JMH- Returns:
- latency in milliseconds per operation
-
calculatePerformanceGrade
Calculates a performance grade based on throughput.- Parameters:
throughput- operations per second- Returns:
- performance grade string
-
formatForDisplay
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
Formats throughput value with appropriate units.- Parameters:
value- throughput in ops/s- Returns:
- formatted string with units
-
formatLatency
Formats latency value with appropriate units.- Parameters:
ms- latency in milliseconds- Returns:
- formatted string with units
-