[How To] Time a Command in Unix

[Unix] Time a Command in Unix

The command calculates the time required to complete a command. The command to be executed is passed as a parameter to the time command. The time command then executed the requested command and then displays the time required to execute the command.

Syntax: time <command> 

Example: time sleep 2

real 0m2.009s
user 0m0.002s
sys 0m0.007s
 
Real is wall clock time - time from start to finish of the call. This is all elapsed time including time slices used by other processes and time the process spends blocked (for example if it is waiting for I/O to complete).

User is the amount of CPU time spent in user-mode code (outside the kernel) within the process. This is only actual CPU time used in executing the process. Other processes and time the process spends blocked do not count towards this figure.

Sys is the amount of CPU time spent in the kernel within the process. This means executing CPU time spent in system calls within the kernel, as opposed to library code, which is still running in user-space. Like 'user', this is only CPU time used by the process.

Vishal Lambe - Time Command Example