QueryPerformanceCounter function (profileapi.h)
Retrieves the current value of the performance counter, which is a high resolution (<1us) time stamp that can be used for time-interval measurements.
Syntax
BOOL QueryPerformanceCounter(
[out] LARGE_INTEGER *lpPerformanceCount
);
Parameters
[out] lpPerformanceCount
A pointer to a variable that receives the current performance-counter value, in counts.
Return value
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError. On systems that run Windows XP or later, the function will always succeed and will thus never return zero.
Remarks
For more info about this function and its usage, see Acquiring high-resolution time stamps.
Examples
// Gets the current number of ticks from QueryPerformanceCounter. Throws an
// exception if the call to QueryPerformanceCounter fails.
static inline int64_t GetTicks()
{
LARGE_INTEGER ticks;
if (!QueryPerformanceCounter(&ticks))
{
winrt::throw_last_error();
}
return ticks.QuadPart;
}
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows 2000 Professional [desktop apps | UWP apps] |
Minimum supported server | Windows 2000 Server [desktop apps | UWP apps] |
Target Platform | Windows |
Header | profileapi.h (include Windows.h) |
Library | Kernel32.lib |
DLL | Kernel32.dll |
See also
Acquiring high-resolution time stamps
Conceptual
GetSystemTimePreciseAsFileTime
Reference