RDTSC-based glcycle_t for macOS

Time profiler implementation is now closer to Windows version
This commit is contained in:
alexey.lysiuk 2017-01-31 16:00:14 +02:00
commit b12c8a8f79
3 changed files with 24 additions and 17 deletions

View file

@ -40,6 +40,8 @@
#include <intrin.h>
#define USE_WINDOWS_DWORD
#elif defined __APPLE__
#include <sys/sysctl.h>
#endif
#include "i_system.h"
@ -114,6 +116,15 @@ void gl_CalculateCPUSpeed ()
gl_SecondsPerCycle = 1.0 / CyclesPerSecond;
gl_MillisecPerCycle = 1000.0 / CyclesPerSecond;
}
#elif defined __APPLE__
long long frequency;
size_t size = sizeof frequency;
if (0 == sysctlbyname("machdep.tsc.frequency", &frequency, &size, nullptr, 0) && 0 != frequency)
{
gl_SecondsPerCycle = 1.0 / frequency;
gl_MillisecPerCycle = 1000.0 / frequency;
}
#endif
}