开发者

How to caluate cpu cycles as that of QueryPerformanceCounter

I have the following code in win32 to calculate cpu cycles using QueryPerformanceCounter()

LARGE_INTEGER ltime; <br>
UINT32 cycles; <br> 
QueryPerformanceCounter(&ltime);<br>

cycles = (UINT32) ((ltime.QuadPart >> 8) & 0xFFF开发者_如何学PythonFFFF);

How do I implement the same on ARM cortex A9 (panda board) running Ubuntu (OMAP4) ????


Your best bet would probably be to use clock_gettime with either CLOCK_PROCESS_CPUTIME_ID or CLOCK_THREAD_CPUTIME_ID. (see clock_gettime)

That will give you "High-resolution per-process timer from the CPU" and "Thread-specific CPU-time clock", respectively.

Alternatively, one could sum up values returned by times, but I guess that would be less precise as it also depends on the scheduler, whereas the above supposedly reads a performance counter from the CPU if possible.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜