If your app simply runs "flat out" (ie it's either using CPU or waiting for I/O) until it exits, and there aren't other processes competing, just do time myapp
(or maybe /usr/bin/time myapp
, which produces slightly different output to the shell builtin).
This will get you something like:
real 0m1.412s
user 0m1.288s
sys 0m0.056s
In this case, user+sys (kernel) time account for almost all the real time and there's just 0.068s unaccounted for... (probably time spent initally loading the app and its supporting libs).
However, if you were to see:
real 0m5.732s
user 0m1.144s
sys 0m0.078s
then your app spent 4.51s not consuming CPU and presumably blocked on IO. Which is the information I think you're looking for.
However, where this simple analysis technique breaks down is:
- Apps which wait on a timer/clock or
other external stimulus (e.g
event-driven GUI apps). It can't
distinguish time waiting on the clock
and time waiting on disk/network.
- Multithreaded apps, which need a bit more thinking about to interpret the numbers.