001/*
002 * Copyright © 2025 CUI-OpenSource-Software (info@cuioss.de)
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package de.cuioss.benchmarking.common.model;
017
018import lombok.Builder;
019import lombok.Data;
020
021import java.util.List;
022import java.util.Map;
023
024/**
025 * Central benchmark data model that can be populated from various sources
026 * (JMH, WRK, custom benchmarks) and used by the reporting infrastructure.
027 */
028@Data
029@Builder
030public class BenchmarkData {
031
032    /**
033     * Metadata about the benchmark run
034     */
035    @Data
036    @Builder
037    public static class Metadata {
038        private String timestamp;
039        private String displayTimestamp;
040        private String benchmarkType;
041        private String reportVersion;
042        private String projectName;
043    }
044
045    /**
046     * Overview metrics for quick summary
047     */
048    @Data
049    @Builder
050    public static class Overview {
051        private String throughput;              // Formatted display value (e.g., "140,0K ops/s")
052        private String latency;                 // Formatted display value (e.g., "952,0 us/op")
053        private Double throughputOpsPerSec;     // Numeric value: operations per second
054        private Double latencyMs;               // Numeric value: latency in milliseconds
055        private String throughputBenchmarkName;
056        private String latencyBenchmarkName;
057        private int performanceScore;
058        private String performanceGrade;
059        private String performanceGradeClass;
060    }
061
062    /**
063     * Individual benchmark result
064     */
065    @Data
066    @Builder
067    public static class Benchmark {
068        private String name;
069        private String fullName;
070        private String mode; // thrpt, avgt, sample, etc.
071        private String score;
072        private String scoreUnit;
073        private Double rawScore; // Numeric value for calculations
074        private String throughput; // For thrpt mode
075        private String latency; // For avgt/sample mode
076        private Double error;
077        private Double variabilityCoefficient;
078        private Double confidenceLow;
079        private Double confidenceHigh;
080        private Map<String, Double> percentiles;
081        private Map<String, Object> additionalData; // For custom metrics
082    }
083
084    private Metadata metadata;
085    private Overview overview;
086    private List<Benchmark> benchmarks;
087    private Map<String, Object> chartData;
088    private Map<String, Object> trends;
089}