package xyz.etztech.serverapi.tps; import java.util.LinkedList; public class TPS implements Runnable { private transient long lastPoll = System.nanoTime(); private final LinkedList history = new LinkedList<>(); @Override public void run() { final long startTime = System.nanoTime(); long timeSpent = (startTime - lastPoll) / 1000; if (timeSpent == 0) { timeSpent = 1; } if (history.size() > 10) { history.remove(); } long tickInterval = 50; float tps = tickInterval * 1000000.0f / timeSpent; if (tps <= 21) { history.add(tps); } lastPoll = startTime; } public LinkedList getHistory() { return history; } }