Class BadgeGenerator
java.lang.Object
de.cuioss.benchmarking.common.report.BadgeGenerator
Generates shields.io compatible JSON badge files for benchmark metrics.
This generator creates three types of badges:
- Performance badge - Shows the current performance grade
- Trend badge - Shows the trend direction with percentage change
- Last run badge - Shows when the benchmarks were last executed
All badges follow the shields.io JSON endpoint schema for easy integration with GitHub README files and documentation.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGenerates a default trend badge when no historical data is available.generateLastRunBadge(Instant timestamp) Generates a last run timestamp badge.generatePerformanceBadge(BenchmarkMetrics metrics) Generates a performance badge JSON based on the benchmark metrics.generateTrendBadge(TrendDataProcessor.TrendMetrics trendMetrics) Generates a trend badge JSON based on the trend metrics.voidwriteBadgeFiles(BenchmarkMetrics metrics, TrendDataProcessor.TrendMetrics trendMetrics, BenchmarkType type, String outputDir) Writes all badge files to the specified directory.voidwriteBadgeFiles(BenchmarkMetrics metrics, TrendDataProcessor.TrendMetrics trendMetrics, String outputDir) Writes all badge files to the specified directory using default MICRO benchmark type.
-
Constructor Details
-
BadgeGenerator
public BadgeGenerator()
-
-
Method Details
-
generatePerformanceBadge
Generates a performance badge JSON based on the benchmark metrics. Format: "Grade A (45k ops/s, 0.15ms)"- Parameters:
metrics- the current benchmark metrics- Returns:
- JSON string for the performance badge
-
generateTrendBadge
Generates a trend badge JSON based on the trend metrics.- Parameters:
trendMetrics- the calculated trend metrics- Returns:
- JSON string for the trend badge
-
generateLastRunBadge
Generates a last run timestamp badge.- Parameters:
timestamp- the benchmark run timestamp- Returns:
- JSON string for the last run badge
-
generateDefaultTrendBadge
Generates a default trend badge when no historical data is available.- Returns:
- JSON string for the default trend badge
-
writeBadgeFiles
public void writeBadgeFiles(BenchmarkMetrics metrics, TrendDataProcessor.TrendMetrics trendMetrics, String outputDir) throws IOException Writes all badge files to the specified directory using default MICRO benchmark type. Convenience overload that defaults toBenchmarkType.MICRO.- Parameters:
metrics- the current benchmark metricstrendMetrics- the trend metrics (can be null)outputDir- the output directory path- Throws:
IOException- if writing badge files fails
-
writeBadgeFiles
public void writeBadgeFiles(BenchmarkMetrics metrics, TrendDataProcessor.TrendMetrics trendMetrics, BenchmarkType type, String outputDir) throws IOException Writes all badge files to the specified directory.- Parameters:
metrics- the current benchmark metricstrendMetrics- the trend metrics (can be null)type- the benchmark type (MICRO or INTEGRATION)outputDir- the output directory path- Throws:
IOException- if writing badge files fails
-