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.

Code Snippets / [DBP] Get Accurate Elapsed Time With PerfTimer and QueryPerformanceFrequency

Author
Message
Todd Riggins
20
Years of Service
User Offline
Joined: 29th Oct 2004
Location: Texas, USA
Posted: 12th Nov 2010 18:43 Edited at: 1st Dec 2010 05:16
Lets make the DBPro Perftimer useful. The global "elaspedTime" here works great for timer based movement. * This code snippet is ported over from my C++ code and gives same results.





EDIT: Thanks for the editing the title

ExoDev.Com - A Game Development Community Website! Featuring: XBOX360 CONTROLLER LIBRARY
Sasuke
18
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 18th Nov 2010 07:51 Edited at: 18th Nov 2010 07:52
Out of interest, whats the advantage of using this method over QueryPerformanceFrequency and QueryPerformanceCounter?

Example:


A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
Todd Riggins
20
Years of Service
User Offline
Joined: 29th Oct 2004
Location: Texas, USA
Posted: 18th Nov 2010 15:07 Edited at: 18th Nov 2010 15:09
Probably none between our two ways.

Well mabie that the DBPro's perftimer command returns the current value of QueryPerformanceCounter so that you wont have to use calldll on it. That's about it.

After searching this topic on the forums and wondering why-oh-why Lee didn't make a perffreq type function to return QueryPerformanceFrequency's value, I just thought I would share code to show an example of use for perftimer with the call to QueryPerformanceFrequency.

ExoDev.Com - A Game Development Community Website! Featuring: XBOX360 CONTROLLER LIBRARY
Todd Riggins
20
Years of Service
User Offline
Joined: 29th Oct 2004
Location: Texas, USA
Posted: 14th Jan 2011 23:36
Just wanted to update that PERFFREQ is now implemented in dbpro 7.7

It returns a double integer value which contains the frequency value of the high-resolution performance counter. Commonly used with PERFTIMER() to get the elasped time which can be used for moving 3d objects at the same speed over different computers.

Here's an example of use:



ExoDev.Com - A Game Development Community Website! Featuring: XBOX360 CONTROLLER LIBRARY

Login to post a reply

Server time is: 2024-11-21 15:48:08
Your offset time is: 2024-11-21 15:48:08