Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Author
Message
Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 1st Sep 2010 17:56
Hey, I've made this small program attempting to show the average fps, but it doesn't work, and I can't find WHY it won't work. The value of avg# seems to start a 0 and works it's way up, never quite reaching the actual fps.



I'm not really fussed about this code, but it's nagging me :p If someone could point out the problem, i'd be grateful

Thanks

LBFN
19
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 1st Sep 2010 18:20


You don't need floating point precision, so just use integers. This code will not start recording FPS data until it is greater than 0. By allowing it to record 0s, you are skewing your average.

So many games to code.......so little time.
Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 1st Sep 2010 18:33
Thanks. I'm aware I don't need floats, I was experimenting to see if in some way that was affecting it. I wasn't aware the FPS would ever equal 0

Thanks for helping out mate

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 1st Sep 2010 18:37
The code does work. You are calculating the long run average since the start of the program. Is that really what you want? Or do you just want the average over, say, the last 100 frames?

Quote: "By allowing it to record 0s, you are skewing your average.
"


Why?
Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 1st Sep 2010 18:41


I've perfected it now.

I agree it was skewing my average, as I only wanted the fps after it had ... warmed up? lol

Thanks

Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 1st Sep 2010 20:48 Edited at: 1st Sep 2010 20:53
Quote: "Quote: "By allowing it to record 0s, you are skewing your average.
"

Why? "

For the first 1000 or so frames, the FPS is 0, as screen FPS() records the previous seconds FPS. So if after the 2nd second the fps is 100, the average FPS for the 2 seconds is 50 FPS. Again, after 3 seconds the average becomes 67 FPS and so on.

That's how it was reading wrong. As mentioned, ignoring FPS readings of 0 should prevent this from occurring.

My signature is NOT a moderator plaything! Stop changing it!
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 1st Sep 2010 23:08
Quote: "That's how it was reading wrong."


It wasn't wrong - he just didn't want the average over all frames. It seems he wanted something else, e.g. the average after a certain number of frames which makes sense of course, i.e. after things have settled down. But ignoring 0 fps would be silly if the fps was in fact 0 (which in practice means something like 0.1 because an integer result is returned).
Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 1st Sep 2010 23:14
GG, i think the guys are right, i just wanted the average of all the frames but without these 0's skewing my results. BTW, why is it that it returns 0?

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 1st Sep 2010 23:25
What would you do if you had my laptop and the fps WAS in fact 0? It's only the initial zeroes you want to exclude.
Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 2nd Sep 2010 02:05
You make a fair point, but the only reason i want the function is so i can measure the fps regardless of what function is being carried out, which drastically affects fps in some cases.

LBFN
19
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 2nd Sep 2010 02:13
Quote: "What would you do if you had my laptop and the fps WAS in fact 0?"

I'd say you're seriously overdue for a computer upgrade.


Seriously, you could just put in a delay to wait one second before you start obtaining/averaging results.

So many games to code.......so little time.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 2nd Sep 2010 14:36
Quote: "I'd say you're seriously overdue for a computer upgrade."


I was wondering who would be first to say that.

Quote: "Seriously, you could just put in a delay to wait one second before you start obtaining/averaging results."


Yes, something like that is all you need - but you should still include any 0's that crop up after that start-up interval. It's surprising how many people exclude zeros from an average on the grounds that "they contain no data". Actually a better way for the present problem might be to simply count the frames and divide by the correspong time, with perhaps something like exponential weighting to ensure the average keeps up with current performance.

Login to post a reply

Server time is: 2026-07-22 19:27:07
Your offset time is: 2026-07-22 19:27:07