CPU utilization for a process in userspace and kernel space

How could I get per process CPU time consumed by this process in kernel mode and CPU time consumed by this process in user mode , top and ps output doesnt seem to show the breakup data
 
Try /usr/bin/time foo to get that for the command "foo". You can also use the various built-in "time" commands from various shells; I like to use the standardized /usr/bin/time instead, so I always get the same output.

You can also keep track of this from within a running program. For example in python, the os.times() function returns it (see the documentation). There are ways to do this in other languages too, and I'm too lazy this evening to look them up. Google is your friend.
 
Back
Top