Если использовать WinAPI, то:
QueryPerformanceCounter
The
QueryPerformanceCounter function retrieves the current value of the high-resolution performance counter.
Syntax
Код:
BOOL QueryPerformanceCounter(
LARGE_INTEGER *lpPerformanceCount
);
Parameters
lpPerformanceCount
[out] 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.
Remarks
On a multiprocessor computer, it should not matter which processor is called. However, you can get different results on different processors due to bugs in the basic input/output system (BIOS) or the hardware abstraction layer (HAL). To specify processor affinity for a thread, use the SetThreadAffinityMask function.
QueryPerformanceFrequency
The
QueryPerformanceFrequency function retrieves the frequency of the high-resolution performance counter, if one exists. The frequency cannot change while the system is running.
Syntax
Код:
BOOL QueryPerformanceFrequency(
LARGE_INTEGER *lpFrequency
);
Parameters
lpFrequency
[out] Pointer to a variable that receives the current performance-counter frequency, in counts per second. If the installed hardware does not support a high-resolution performance counter, this parameter can be zero.
Return Value
If the installed hardware supports a high-resolution performance counter, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError. For example, if the installed hardware does not support a high-resolution performance counter, the function fails.