2022-04-16 11:00:32 +00:00
|
|
|
|
|
|
|
// I think this SO post might be helpful
|
|
|
|
// https://stackoverflow.com/questions/30575995/multi-platform-equivalent-to-queryperformancecounter
|
|
|
|
|
|
|
|
Ticks
|
|
|
|
os_get_ticks()
|
|
|
|
{
|
|
|
|
Ticks result = {
|
|
|
|
.value = mach_absolute_time()
|
|
|
|
};
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2022-08-08 09:39:42 +00:00
|
|
|
global mach_timebase_info_data_t osx_timebase_info;
|
|
|
|
|
2022-04-16 11:00:32 +00:00
|
|
|
r64
|
|
|
|
os_get_ticks_per_second()
|
|
|
|
{
|
2022-08-08 09:39:42 +00:00
|
|
|
if (osx_timebase_info.denom == 0) {
|
|
|
|
mach_timebase_info(&osx_timebase_info);
|
|
|
|
}
|
|
|
|
r64 to_secs = ((r64)osx_timebase_info.denom * 1e9) / (r64)osx_timebase_info.numer;
|
2022-04-16 11:00:32 +00:00
|
|
|
return to_secs;
|
|
|
|
}
|