MCPcopy Create free account
hub / github.com/beefytech/Beef / BfpSystem_GetCPUTickFreq

Function BfpSystem_GetCPUTickFreq

BeefySysLib/platform/win/Platform.cpp:1196–1219  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1194}
1195
1196BFP_EXPORT int64 BFP_CALLTYPE BfpSystem_GetCPUTickFreq()
1197{
1198 LARGE_INTEGER largeVal = { 0 };
1199 QueryPerformanceFrequency(&largeVal);
1200 int64 qpfFreq = largeVal.QuadPart;
1201
1202 if (gStartCPUTick == -1)
1203 {
1204 InitCPUFreq();
1205 Sleep(10);
1206 }
1207
1208 int64 cpuTick1 = __rdtsc();
1209 QueryPerformanceCounter(&largeVal);
1210 int64 slowTick1 = largeVal.QuadPart;
1211
1212 int64 cpuElapsed = cpuTick1 - gStartCPUTick;
1213 int64 slowElapsed = slowTick1 - gStartQPF;
1214 double elapsedSeconds = slowElapsed / (double)qpfFreq;
1215 int64 freq = (int64)(cpuElapsed / elapsedSeconds);
1216 gCPUFreq = freq;
1217
1218 return gCPUFreq;
1219}
1220
1221BFP_EXPORT void BFP_CALLTYPE BfpSystem_CreateGUID(BfpGUID* outGuid)
1222{

Callers 1

ThreadProcMethod · 0.50

Calls 2

InitCPUFreqFunction · 0.85
SleepFunction · 0.50

Tested by

no test coverage detected