Using time to get CPU usage of a process, but not its children

5

2

When using time some_executable - the system and user CPU time returned actually includes all the CPU time of any child processes launched by the named executable (this was news to me, actually).

I would like to get just the CPU time incurred by the launched process, however, and not its children. Is that possible?

BeeOnRope

Posted 2012-07-25T20:31:34.460

Reputation: 744

1from man time: Note: some shells (e.g., bash(1)) have a built-in time command that provides less functionality than the command described here. To access the real command, you may need to specify its pathname (something like /usr/bin/time). I had to install time, but its output is way more verbose (than the built in time), maybe it helps you. – Baarn – 2012-07-25T21:37:56.407

Answers

2

If you are benchmarking a piece of software, you can get VERY fine-grained results with something like callgrind (valgrind --tool=callgrind).

If you're looking for something a tad weaker, /proc/$PID/schedstat contains useful numbers (such as "time this thread has used").

zebediah49

Posted 2012-07-25T20:31:34.460

Reputation: 493