Skip to main content
GameDev.net gamedev.net
🔒 Locked

timing events...

Started by sathenzar Nov 24, 2004 at 5:39 PM 0 replies 300+ views
Original Post
sathenzar
sathenzar
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.
Wavarian
Wavarian
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));}

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.