I am trying to get the CPU time spent on a process on Ubuntu. As far as I know, two functions can do this job: getrusage () and clock_gettime (CLOCK_PROCESS_CPUTIME_ID, & tp). In my code, calling getrusage () immediately after clock_gettime (CLOCK_PROCESS_CPUTIME_ID, & tp) always gives different results.
Can someone help me understand which function gives higher resolution and what advantages / disadvantages of these functions have?
Thank.
source
share