FPS Counter
I didn''t know whether this is considered graphics, or general programming, so if this doesn''t belong here, apologize. Anyway, I was wondering if anyone has the code to a simple FPS counter, it sucks not knowing if anything you are doing is improving the framerate. Even if the framerate is output to a text file every update it would be fine. Thanks!
-Taphreek
Not a n00b, even if can''t write a basic FPS counter
-Taphreek
HEHE Well i will give you a VB Sample
Private FPS as single
Private Time1 as long
Private P as byte
Private Sub Form_Load()
Time1 = getTickCount
do
DoEvents
.....
do your stuff here
.....
if p = 9 then
p=0
FPS = 10000/(getTickCount-Time1)
Time1 = getTickCount
debug.print FPS
end if
p=p+1
loop
End Sub
-VBLimits
Sorry about the Spelling..
Private FPS as single
Private Time1 as long
Private P as byte
Private Sub Form_Load()
Time1 = getTickCount
do
DoEvents
.....
do your stuff here
.....
if p = 9 then
p=0
FPS = 10000/(getTickCount-Time1)
Time1 = getTickCount
debug.print FPS
end if
p=p+1
loop
End Sub
-VBLimits
Sorry about the Spelling..
![](http://www.telusplanet.net/public/javaman/img/Title.gif)
Uh, vb sucks, get out of here w/ that code.
Tap, search the forums for "fps counter" or something like that, the question has been asked alot, you should find it in no time
Tap, search the forums for "fps counter" or something like that, the question has been asked alot, you should find it in no time
![](smile.gif)
yeah, some details about what your using would be nice...
Windows/Linux/Ect...
What windowing system(glut?), ect...
Windows/Linux/Ect...
What windowing system(glut?), ect...
|
Single-pole, digitally filtered Frame Rate.
Magmai Kai Holmlor
- The disgruntled & disillusioned
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
I give you a simple (however not quite as accurate) example in Allegro.
|
Ok here''s a simple way to do it, but it''s not that accurate:
You call this function at the end of every frame.
There is also the more accurate way which is done in the VB Sample. In C it would be similar something like...
DWORD Time1 = GetTickCount();
...Render Frame...
FPS = 10000/(GetTickCount()-Time1);
Time1 = GetTickCount();
Digital Radiation
int Get_FPS(void){ static DWORD fps_time1=GetTickCount(); static int fps_count, fps; DWORD fps_time2 = GetTickCount(); fps_count++; if(fps_time2-fps_time1 >= 1000) { fps_time1=GetTickCount(); fps=fps_count; fps_count=0; } return fps;}
You call this function at the end of every frame.
There is also the more accurate way which is done in the VB Sample. In C it would be similar something like...
DWORD Time1 = GetTickCount();
...Render Frame...
FPS = 10000/(GetTickCount()-Time1);
Time1 = GetTickCount();
Digital Radiation
March 11, 2001 10:14 AM
Well, if you''re using a Windows based system....
I hope that all looks good. Anyway. There are plenty of examples of using the Performance timer in the MSDN help at http://msdn.microsoft.com
Sorry it looks so bad. I cut out the rest of the engine and we plan on cutting anything with //DEBUG out of the code. =)
E.D.
|
I hope that all looks good. Anyway. There are plenty of examples of using the Performance timer in the MSDN help at http://msdn.microsoft.com
Sorry it looks so bad. I cut out the rest of the engine and we plan on cutting anything with //DEBUG out of the code. =)
E.D.
Sorry that was me in that last post. It doesn''t look quite the way I wanted it to but oh well.
Its really accurate, pretty fast, and down to millisecond level. (in case you don''t know your FPS is equal to 1/ms where ms is the milliseconds. So for example, my engine takes 9 milliseconds to do its rendering, therefore, I''m running at about 111 FPS. When I include data processing in the loop, it takes about 15 milliseconds which is 66 FPS. Etc... you get the point.)
E.D.
Its really accurate, pretty fast, and down to millisecond level. (in case you don''t know your FPS is equal to 1/ms where ms is the milliseconds. So for example, my engine takes 9 milliseconds to do its rendering, therefore, I''m running at about 111 FPS. When I include data processing in the loop, it takes about 15 milliseconds which is 66 FPS. Etc... you get the point.)
E.D.
Enoch DagorLead DeveloperDark Sky EntertainmentBeyond Protocol
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement