QueryPerformanceCounter
-
What does QueryPerformanceFrequency measure? units per second?
-
What does QueryPerformanceFrequency measure? units per second?
Here's how I get the current time (in ticks):
TimePoint SysTickTimer::Now() const
{
if(available_) // previously set based on whether high-frequency timing is available
{
LARGE_INTEGER now;
QueryPerformanceCounter(&now);
return TimePoint(now.QuadPart); // the current time in ticks (64 bits)
}
else // will only have millisecond accuracy
{
_timeb now;
_ftime_s(&now);
auto msecs = 1000LL * now.time;
return TimePoint(msecs + now.millitm);
}
}My Windows 10 installation, running on a Dell XPS15, has 10^7 ticks per second (1 tick = 0.1 usecs). This is determined by
LARGE_INTEGER frequency;
if(QueryPerformanceFrequency(&frequency))
{
available_ = true;
ticks_per_sec_ = frequency.QuadPart;
}Robust Services Core | Software Techniques for Lemmings | Articles
-
What does QueryPerformanceFrequency measure? units per second?
-
Here's how I get the current time (in ticks):
TimePoint SysTickTimer::Now() const
{
if(available_) // previously set based on whether high-frequency timing is available
{
LARGE_INTEGER now;
QueryPerformanceCounter(&now);
return TimePoint(now.QuadPart); // the current time in ticks (64 bits)
}
else // will only have millisecond accuracy
{
_timeb now;
_ftime_s(&now);
auto msecs = 1000LL * now.time;
return TimePoint(msecs + now.millitm);
}
}My Windows 10 installation, running on a Dell XPS15, has 10^7 ticks per second (1 tick = 0.1 usecs). This is determined by
LARGE_INTEGER frequency;
if(QueryPerformanceFrequency(&frequency))
{
available_ = true;
ticks_per_sec_ = frequency.QuadPart;
}Robust Services Core | Software Techniques for Lemmings | Articles
it`s ticks per second. Thanks Greg for showing how you handle it.
-
All explained in the documentation: QueryPerformanceFrequency function - Win32 apps | Microsoft Docs[^].
thanks, I got it working.