Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • I see what you mean. Thanks! In addition, I did some additional testing and looks like top -d 1 works in a way that it really measures process CPU usage within the one second, e.g. if burnP6 is started at the half of this interval(at 0.5s), then the CPU usage of burnP6 is shown as 50%. This can be tested if while true; do /usr/bin/burnP6 & sleep 1; pkill burnP6; done is running and one starts the top -d 1 at different times. This obviously means that if process really runs only for 30ms, then the maximum load one can see for this process in top output is 30%. Do you agree? Commented Nov 21, 2014 at 11:07
  • @Martin If you want reliable data about CPU usage, you need to sample for a time that's less than the lifetime of the process. When you start a new instance of burnP6 every second, with top refreshing every second, you may see a figure that's lower than the actual usage. On the second refresh of top showing the same process instance, you'll get a reliable figure. Commented Nov 21, 2014 at 11:11
  • Exactly. Is there an utility which allows to measure CPU usage for micro- or millisecond intervals? Commented Nov 21, 2014 at 11:38
  • @Martin Microsecond intervals wouldn't make sense, that's smaller than a time slice. Intervals of about 0.1s should give decent results, try top -d 0.1. Commented Nov 21, 2014 at 12:30