I am trying to conduct some experiments for determining what the CPU utilization of my process is. I am familiar with the top and ps commands. Which would be a better solution for getting the average CPU utilization of my process throughout the entire time? From this question it seems like ps would be the best way. Would using top periodically to record stats and averaging the results be more precise?


It sounds like the gprof might be what you are looking for. It'll help with debugging to figure out how much time is spent in a function.

You might also want to check out this stack exchange answer: How does “top” calculate CPU usage?

  • I'm not looking to profile my app. I just want to show what the overall avg CPU utilization for the process is on running it for an hour
    – RagHaven
    Dec 2 '14 at 16:46
  • 1
    @AndroidDev93 I think the stack exchange answer is what you're looking for then. Just have a separate program\script constantly read from /proc
    – SailorCire
    Dec 2 '14 at 16:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.