什么是OSX上的Windows QueryPerformanceCounter的等价物?

我正在将一个库从Windows移植到* NIX(现在是OSX),现在没有人可以使用什么函数来代替Microsoft的QueryPerformanceCounter和QueryPerformanceFrequency?

http://www.tin.org/bin/man.cgi?section=3&topic=clock_gettime (和那里提到的其他功能) – 这是Posix! 如果HPET不存在,将回落到更糟糕的计数器。 (虽然不应该是个问题)

http://en.wikipedia.org/wiki/High_Precision_Event_Timer

分辨率应该是+ 10Mhz左右。

在OSX上, mach_absolute_timemach_timebase_info是Win32 QueryPerformance *函数的最佳等价物。

请参阅http://developer.apple.com/library/mac/#qa/qa1398/_index.html

尝试升压的便携式高分辨率时间ptime 。

更新 (提示,2年后,Mark的评论如下):

这些天我会使用std::chrono::high_resolution_clock ; 例如 。

他询问了关于OS X.使用CoreAudio的这些API:

 AudioConvertHostTimeToNanos(AudioGetCurrentHostTime()) 

回到当天,你有时钟,或者你钻入汇编器读取RDTSC 。

G。