Como pegar o FPS em java?

Gostaria de saber alguma forma para eu poder saber o fps que está rodando o meu jogo, tem como?

int totalFrameCount = 0;
TimerTask updateFPS = new TimerTask() {
public void run() {
    // display current totalFrameCount - previous,
    // OR
    // display current totalFrameCount, then set
    totalFrameCount = 0;
}
}

Timer t = new Timer();
t.scheduleAtFixedRate(updateFPS, 1000, 1000);

while (running) {
// your code
totalFrameCount++;
}

Tenda esse code. Obs: Não testei.