public int fps;
private int frames;
private long fpsTimer;
public double deltaTime;
private double lastDeltaTime;
public boolean calculatePerformance;
public Thread thread = new Thread() {
public void run() {
while(running) {
if(calculatePerformance) calculatePerformance();
}
}
};
private final void calculatePerformance() {
frames++;
if(System.currentTimeMillis() - fpsTimer >= 1000L) {
fpsTimer = System.currentTimeMillis();
fps = frames;
frames = 0;
}
deltaTime = (System.nanoTime() - lastDeltaTime) / 1_000_000_000.0D;
lastDeltaTime = System.nanoTime();
}