2009-01-14 20:51:17 +00:00
|
|
|
// Small script that prints the FPS to screen with regular intervals.
|
|
|
|
|
2009-01-20 08:29:15 +00:00
|
|
|
import io, timer, frames;
|
2009-01-14 20:51:17 +00:00
|
|
|
|
2009-01-20 08:29:15 +00:00
|
|
|
// Sleep one frame. This makes sure that we won't start running until
|
|
|
|
// the rendering begins. Not critically important, but it prevents the
|
|
|
|
// first printed value from being 'nan'.
|
|
|
|
fsleep(1);
|
|
|
|
|
|
|
|
ulong lastFrame = counter;
|
|
|
|
float lastTime = totalTime;
|
2009-01-14 20:51:17 +00:00
|
|
|
|
|
|
|
float delay = 1.5;
|
|
|
|
|
2009-01-20 08:29:15 +00:00
|
|
|
while(true)
|
2009-01-14 20:51:17 +00:00
|
|
|
{
|
|
|
|
sleep(delay);
|
2009-01-20 08:29:15 +00:00
|
|
|
|
|
|
|
// Calculate differences since last frame
|
|
|
|
ulong fdiff = counter-lastFrame;
|
|
|
|
float tdiff = totalTime-lastTime;
|
|
|
|
|
|
|
|
print("fps:", fdiff / tdiff);
|
|
|
|
|
|
|
|
lastFrame = counter;
|
|
|
|
lastTime = totalTime;
|
2009-01-14 20:51:17 +00:00
|
|
|
}
|