frame rate measurement

Started by
4 comments, last by mike74 18 years, 10 months ago
I'm writing a maze game, and I'd like an easy way to compare its frame rate to that of Unreal. Unfortunately, the "fraps" utility doesn't work on my PC - it says I need a processor that supports "SSE" instructions. Does anyone know of any good alternatives to fraps? I've looked, and so far, nothing's turned up. Mike C. http://www.coolgroups.com/zoomer/
Mike C.http://www.coolgroups.com/zoomer/http://www.coolgroups.com/ez/
Advertisement
Here's what I do (programming in Windows, Dev-C++):
//Global Variables:ULONG FRAME_START;float FPS; //It can have floating-point frame-rates//Beginning of the frameFRAME_START=GetTickCount(); //This time is measured in milliseconds...//End of the frameif (FRAME_START!=GetTickCount()) FPS=(float)1000/(GetTickCount()-FRAME_START);

And if you want to control your frame rate, use a while loop with a condition that checks if a certain amount of time has passed since FRAME_START.
Projects:> Thacmus - CMS (PHP 5, MySQL)Paused:> dgi> MegaMan X Crossfire
Be warned:
For most projects it may not matter, but GetTickCount isn't especially accurate. It's (I believe) preferred to use QueryPerformanceCounter. But once again, it may not matter if it's 10ms off for your project. It probably doesn't.

Good luck.
The best way to predict the future is to invent it.
Here is a function that I call each frame to calculate FPS (updates every second) and calculates the elapsed time from previous frame to current frame which I use for movement calculations. You will have to alter it to fit your project.

void CBApp::CalculateFrameTime() {	mFrameCount++;	DWORD time = timeGetTime();	if ((time-1000)>mBeginTime) {	   mFPS=mFrameCount;	   mFrameCount=0;	   mBeginTime+=1000;	}	mElapsedTime = time - mLastFrameTime;	mLastFrameTime = time;}


Edit: To ensure you get 1ms accuracy with timeGetTime, you need to put this at the beginning of your program:

timeBeginPeriod(1);

and this at the end:

timeEndPeriod(1);

I believe you also have to link to winmm.
ricekrispyw >> I never knew about QueryPerformanceCounter... What's the scale for this? Milliseconds (1/1000 second), Nanosecond (1/? second)? How would I implement this in a similar form as my code above?
Projects:> Thacmus - CMS (PHP 5, MySQL)Paused:> dgi> MegaMan X Crossfire
Interesting. Is there a way to measure Unreal's frame rate though?


Mike C.
http://www.coolgroups.com/zoomer/
Mike C.http://www.coolgroups.com/zoomer/http://www.coolgroups.com/ez/

This topic is closed to new replies.

Advertisement