문제

I want to measure the execution time of a c-code segment using Linux. I take one timestamps at the beginning of the code segment and one at the end. But I don't know how to protect the code against IRQs and context switches to high prior tasks. The program runs in user space! The code segment is short so don't panic hosing the system.

Does anyone know an easy solution for this kind of protection?

도움이 되었습니까?

해결책

You can use getrusage(2) to get the CPU time used, rather than just measuring real time. That should get you the answer you want without having to resort to funny business like blocking other programs from running.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top