• Advertisement


This topic is now archived and is closed to further replies.

[java] Java 1.1 Time

This topic is 6066 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I wanted to know how I could setup a fps meter in java 1.1. Basically I was thinking I could use the system clock and then divide by how much the thread repaints itself. Unfortunely I'm not familiar with java and doing things like that. Edited by - Black Marq on July 17, 2001 6:34:13 PM

Share this post

Link to post
Share on other sites

Will get you a rough approximation of the number of milliseconds have passed since windows started. So as long as you keep track of how many frames you have painted with a ...

private long frames = 0;

repaint(Graphics g) //or whatever else you are using

And when before you start your FIRST frame.

startTime = System.currentTimeMillis();

Then your average fps can be calcualted with...

fps = (double)(1000 * frame) / (double)(System.currentTimeMillis() - startTime;

should give you an approximate fps counter.


currentTimeMillis() is only accureate to about 50ms under windows, so it is useless for any timing of things over 10-15fps unless averaged against several frames.

Share this post

Link to post
Share on other sites

  • Advertisement