• Advertisement
Sign in to follow this  

timing events...

This topic is 4835 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

Hey, I wanted to know if there was a function to get the amount of seconds the application of mine has been running. GetTickCount doesn't work, b/c it just generates milliseconds which isn't accurate b/c every second is like some odd 54,000 milliseconds when u use it. So is there a way where I could have an int time = sometimefuction();? I'm trying to create a timing even so every few seconds it does a different action. Thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
Hmmm.. That's strange.. Since there are only 1000 milliseconds in a second. Anyhow, you could look into a high resolution timer:


#include <windows.h>

void main() {

LARGE_INTEGER freq,start,stop;

// Initialize the "timer"
QueryPerformanceFrequency(&freq);

// Start the "timer"
QueryPerformanceCounter(&start);

// Do stuff
...

// Stop the timer
QueryPerformanceCounter(&stop);

int secondsElapsed = int((stop.QuadPart - start.QuadPart) / float(freq.QuadPart));
}

Share this post


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

  • Advertisement