
(alias time).Įtime ELAPSED elapsed time since the process was started, hh:]mm:ss.Įtimes ELAPSED elapsed time since the process was started, in seconds.
CPU UTIME STIME CODE
$ ps -p -o cputime,etimes CODE HEADER DESCRIPTIONĬputime TIME cumulative CPU time, "hh:mm:ss" format. say you want to monitor the average CPU load of plugin-container in Firefox while doing some Firefox-related task.

This could be useful to calculate CPU usage over a longer period. When thinking about it it could actually be rather useful, with some limitations. One could use times provided by ps and calculate CPU usage from this. Process CPU time : 485,286 jiffies 4,852 seconds Pcpu = (total_time * 1000 / Hertz) / secondsĮxample (Output from a custom Bash script): $. Total_time = total_time + cutime + cstime The actual calculation is done by: total_time = utime + stime So if utime is 1234 and Hertz is 100 then: seconds = utime / Hertz = 1234 / 100 = 12.34 So in addition it uses various methods, ie., sysconf(_SC_CLK_TCK), to get system's Hertz (number of ticks per second) - ultimately using 100 as a fall-back after exhausting other options. From uptime it uses the first value ( uptime).ġ4 utime CPU time spent in user code, measured in jiffiesġ5 stime CPU time spent in kernel code, measured in jiffiesġ6 cutime CPU time spent in user code, including time from childrenġ7 cstime CPU time spent in kernel code, including time from childrenĢ2 starttime Time when the process started, measured in jiffiesĪ jiffie is clock tick.proc//stat Status information about the process.

When ps calculates CPU usage it uses two files: /proc/uptime The uptime of the system (seconds), and the amount of time spent in idle process (seconds). So, for example the process from your question had a folder at /proc/3038/. In addition each process has its own sub folder /proc// where process specific data is stored. You have some files in root of /proc/ that have various information about the overall state of the system. Ps, as well as top, uses data from files stored under /proc/ - or the process information pseudo-file system. In 84,7% of the time it has not been bugging on the CPU. So the number printed is: time the process has been using the CPU during it's lifetime. Pu_time = total time process has been using the CPU. Ps_time = process start time measured in seconds from boot. Uptime = total time system has been running. Ps calculates CPU usage in the following manner: Ps could have given current usage – but that would require it to read data multiple times and sleep between each read. Top on the other hand keep polling numbers and calculate load over time.

Giving: If ps should give instant CPU usage it would be either 0% or 100%. Thus you have either 0% or 100% load in that exact moment.

Think of it like this: At any given moment a process either uses the CPU or not. While top is a monitoring tool, ps is a snapshot tool. It is like asking someone to calculate the speed of a car from a picture.
CPU UTIME STIME HOW TO
" Hmm yeah i Wonder how to get that (the instant CPU percentage) from ps" CPU usage isĪnd, guess you know, but you can also do: top -p Įdit: as to your comment on other answer This is not ideal, and it does notĬonform to the standards that ps otherwise conforms to. CPU usage is currently expressed as the percentage of time spent runningĭuring the entire lifetime of a process. Make_all_argv_opts(argv) /* options can be specified w/o dash */Ĭol = getopt32(argv, "d:n:bHm", &str_interval, &str_iterations) Int top_main(int argc UNUSED_PARAM, char **argv)
