RDTSC-based glcycle_t for macOS
Time profiler implementation is now closer to Windows version
This commit is contained in:
parent
1cdfcb4935
commit
b12c8a8f79
3 changed files with 24 additions and 17 deletions
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue