Skip to main content
gamedev.net
🔒 Locked

QPC timer problem

Started by Lupin 0 replies 1.6k views
Original Post
Lupin
Lupin
how could I get an time-value using the QPC-timer in seconds?
Sharky
Sharky
At the start of your app/game get the frequency of the performance counter...

LARGE_INTEGER timerFreq;
QueryPerformanceFrequency(&timerFreq);

Then call the QueryPerformanceCounter function to obtain some values for timing... (example)

LARGE_INTEGER startTime;
LARGE_INTEGER endTime;

QueryPerformanceCounter(&startTime);
// do some stuff here...
QueryPerformanceCounter(&endTime);

double timeInSecs;
timeInSecs = (double)((double)(endTime.QuadPart - startTime.QuadPart) / (double)timerFreq.QuadPart);

timeInSecs holds the time taken (in seconds) to do the ''stuff''.
Hopefully this will help and give you a place to start from.

Regards,
Sharky

Topic Locked

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

Sign in to reply to this topic.