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.jfr;
017
018import jdk.jfr.*;
019
020/**
021 * Periodic JFR event that captures operation statistics over time windows.
022 * This event is emitted periodically to track variance and performance trends.
023 */
024@Name("de.cuioss.benchmark.OperationStatistics")
025@Label("Operation Statistics")
026@Description("Periodic statistics for benchmark operations including latency percentiles and variance metrics")
027@Category({"Benchmark", "Performance", "Statistics"})
028@Period("1 s")
029@StackTrace(false)
030public class OperationStatisticsEvent extends Event {
031
032    @Label("Benchmark Name")
033    @Description("Name of the benchmark")
034    public String benchmarkName;
035
036    @Label("Operation Type")
037    @Description("Type of operation")
038    public String operationType;
039
040    @Label("Sample Count")
041    @Description("Number of operations in this time window")
042    public long sampleCount;
043
044    @Label("Success Count")
045    @Description("Number of successful operations")
046    public long successCount;
047
048    @Label("Error Count")
049    @Description("Number of failed operations")
050    public long errorCount;
051
052    @Label("Mean Latency")
053    @Description("Mean operation latency")
054    @Timespan
055    public long meanLatency;
056
057    @Label("P50 Latency")
058    @Description("50th percentile (median) latency")
059    @Timespan
060    public long p50Latency;
061
062    @Label("P95 Latency")
063    @Description("95th percentile latency")
064    @Timespan
065    public long p95Latency;
066
067    @Label("P99 Latency")
068    @Description("99th percentile latency")
069    @Timespan
070    public long p99Latency;
071
072    @Label("Max Latency")
073    @Description("Maximum observed latency")
074    @Timespan
075    public long maxLatency;
076
077    @Label("Standard Deviation")
078    @Description("Standard deviation of latencies")
079    @Timespan
080    public long standardDeviation;
081
082    @Label("Variance")
083    @Description("Variance of latencies in nanoseconds squared")
084    public double variance;
085
086    @Label("Coefficient of Variation")
087    @Description("Coefficient of variation (CV) as a percentage")
088    public double coefficientOfVariation;
089
090    @Label("Concurrent Threads")
091    @Description("Number of concurrent threads during this period")
092    public int concurrentThreads;
093
094    @Label("Cache Hit Rate")
095    @Description("Percentage of operations served from cache")
096    public double cacheHitRate;
097}