package com.xfestudio.xfeservermanager.api.status;

public record TickMetrics(double tps, double msptAverage, double msptP95, double msptP99, double jitter) {
    public TickMetrics {
        validate(tps, "tps");
        validate(msptAverage, "msptAverage");
        validate(msptP95, "msptP95");
        validate(msptP99, "msptP99");
        validate(jitter, "jitter");
    }

    private static void validate(double value, String name) {
        if (!Double.isFinite(value) || value < 0.0) {
            throw new IllegalArgumentException(name + " must be finite and non-negative");
        }
    }
}
