Jump to content
  • Advertisement
Sign in to follow this  
EvilNando

measuring FPS - what Im doing wrong

This topic is 3609 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Im making a xna device on winforms, hence Im not inheriting from the Game class , so I think doing this will not cap my render time to 60fps like it would be if I where using the Game class. this is what Im doing to measure FPS, timer_end = DateTime.Now.Ticks; Int64 lapse = timer_end - timer_start; ts = new TimeSpan(lapse); timer_start = DateTime.Now.Ticks; if ( 1000 / ts.Milliseconds > 60 ) // 60fps limit { return; } Render(); The problems is that Im always getting 30fps from measuring 1000/ts.Milliseconds any ideas

Share this post


Link to post
Share on other sites
Advertisement
60hz gives a frame time of ~16ms which is well within the margin of error for DateTime. Try the same code but with a Stopwatch instead - it should be sufficiently accurate.

Note that capping FPS like this is a bit old-school and a pretty hacky way of doing things, especially as it can really show itself up with jerky/erratic animation. Look into "time base animation" or "time based modelling" as it'll scale well according to the hardware...

hth
Jack

Share this post


Link to post
Share on other sites
Quote:
Original post by EvilNando
can you guys help me out
What debugging have you done? Can you share your analysis and any comparison with sample code you can find online - this sort of throttling will be included in many freely available web samples...

Please remember - help us to help you [smile]

Cheers,
Jack

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!