1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-09 21:42:13 +00:00
OpenMW/mscripts/fpsticker.mn

30 lines
683 B
Plaintext
Raw Normal View History

// Small script that prints the FPS to screen with regular intervals.
import frames;
// 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);
// counter and totalTime (in the 'frames' module) are updated
// automatically by the system.
ulong lastFrame = counter;
float lastTime = totalTime;
float delay = 1.5;
while(true)
{
sleep(delay);
// Calculate differences since last frame
ulong fdiff = counter-lastFrame;
float tdiff = totalTime-lastTime;
print("fps:", fdiff / tdiff);
lastFrame = counter;
lastTime = totalTime;
}