Using the time command to measure microprocessor use
Use the time command to understand the performance characteristics of a single program and its synchronous children.
The time command reports the real time, that is the elapsed time from beginning to end of the program. It also reports the amount of microprocessor time used by the program. The microprocessor time is divided into user and sys. The user value is the time used by the program itself and any library subroutines it calls. The sys value is the time used by system calls invoked by the program (directly or indirectly).
The sum of user + sys is the total direct microprocessor cost of executing the program. This does not include the microprocessor costs of parts of the kernel that can be said to run on behalf of the program, but which do not actually run on its thread. For example, the cost of stealing page frames to replace the page frames taken from the free list when the program started is not reported as part of the program's microprocessor consumption.
real - (user + sys)
real * number_of_processors - (user + sys)
In approximately the order of diminishing size, the factors can be:
- I/O required to bring in the program's text and data
- I/O required to acquire real memory for the program's use
- microprocessor time consumed by other programs
- microprocessor time consumed by the operating system
# time looper
# time nice -n 10 looper
# nice -n 10 time looper
we would have gotten a different time command (/usr/bin/time) with a lower-precision report, rather than the version of the time command we have been using, which is built into the ksh shell. If the time command comes first, you get the built-in version, unless you specify the fully qualified name of /usr/bin/time. If the time command is invoked from another command, you get /usr/bin/time.