Time Counter
- 高精度计时
#include <windows.h>
// 计时
double PCFreq = 0.0;
__int64 CounterStart = 0;
void StartCounter() {
LARGE_INTEGER li;
if (!QueryPerformanceFrequency(&li))
cout << "QueryPerformanceFrequency failed!\n";
PCFreq = double(li.QuadPart) / 1000.0;
QueryPerformanceCounter(&li);
CounterStart = li.QuadPart;
}
double GetCounter() {
LARGE_INTEGER li;
QueryPerformanceCounter(&li);
return double(li.QuadPart - CounterStart) / PCFreq;
}
Last update:
December 2, 2023
Created: December 2, 2023
Created: December 2, 2023