FPS (Frames per second) ermitteln

Thomas Darimont

Erfahrenes Mitglied
Servus!

Hier mal eine Methode wie man ganz einfach die FPS einer Grafikanwendung unter Java ermitteln kann:
Code:
long firstFrame;
int frames;
long currentFrame;
int fps;

...

 //nun in paint() / update() bzw. paintComponent() ...

  frames++;
  currentFrame = System.currentTimeMillis();
  if(currentFrame > firstFrame + 1000){
     firstFrame = currentFrame;
     fps = frames;
     frames = 0;
  }

...

g.drawString(fps + " fps");

fertig!

Gruß Tom
 
Zurück