Timeline for Does it take time for process to utilize CPU?
Current License: CC BY-SA 3.0
6 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Nov 21, 2014 at 14:31 | vote | accept | Martin | ||
| Nov 21, 2014 at 12:30 | comment | added | Gilles 'SO- stop being evil' |
@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.
|
|
| Nov 21, 2014 at 11:38 | comment | added | Martin | Exactly. Is there an utility which allows to measure CPU usage for micro- or millisecond intervals? | |
| Nov 21, 2014 at 11:11 | comment | added | Gilles 'SO- stop being evil' |
@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.
|
|
| Nov 21, 2014 at 11:07 | comment | added | Martin |
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?
|
|
| Nov 20, 2014 at 2:28 | history | answered | Gilles 'SO- stop being evil' | CC BY-SA 3.0 |