Search in sources :

Example 1 with TPSInstance

use of com.kahzerx.kahzerxmod.profiler.instances.TPSInstance in project KahzerxMod by otakucraft.

the class TPSProfiler method onTick.

@Override
public void onTick(MinecraftServer server, String id) {
    if (server.getTicks() % TPS_SAMPLE_INTERVAL != 0) {
        this.addResult(server.getTicks(), new ProfilerResult("tps", id, new TPSInstance(tps5Sec(), tps10Sec(), tps1Min(), tps5Min(), tps10Min())));
        return;
    }
    long now = System.nanoTime();
    if (this.lastTickTime == 0) {
        this.addResult(server.getTicks(), new ProfilerResult("tps", id, new TPSInstance(20.0D, 20.0D, 20.0D, 20.0D, 20.0D)));
        this.lastTickTime = now;
        return;
    }
    long diff = now - this.lastTickTime;
    BigDecimal currentTps = TPS_BASE.divide(new BigDecimal(diff), 30, RoundingMode.HALF_UP);
    BigDecimal total = currentTps.multiply(new BigDecimal(diff));
    for (TpsRollingAverage rollingAverage : this.tpsAverages) {
        rollingAverage.add(currentTps, diff, total);
    }
    this.lastTickTime = now;
    this.addResult(server.getTicks(), new ProfilerResult("tps", id, new TPSInstance(tps5Sec(), tps10Sec(), tps1Min(), tps5Min(), tps10Min())));
}
Also used : TPSInstance(com.kahzerx.kahzerxmod.profiler.instances.TPSInstance) ProfilerResult(com.kahzerx.kahzerxmod.profiler.instances.ProfilerResult) BigDecimal(java.math.BigDecimal)

Aggregations

ProfilerResult (com.kahzerx.kahzerxmod.profiler.instances.ProfilerResult)1 TPSInstance (com.kahzerx.kahzerxmod.profiler.instances.TPSInstance)1 BigDecimal (java.math.BigDecimal)1