Find the duration of execution of a particular command on Unix/OS X/FreeBSD

Fig.02: Determine the duration of execution of a particular command on Unix/OSX

Fig.02: Determine the duration of execution of a particular command on Unix/OSX

Simple type the following command on a Unix, OS X or FreeBSD based system to find out the duration of execution of host command:
$ time date
Sample outputs:

Tue Dec  8 15:42:02 IST 2015
 
real	0m0.005s
user	0m0.001s
sys	0m0.003s
  1. The real time is nothing but time time elapsed between invocation of utility and its termination.
  2. The User CPU time, equivalent to the sum of the tms_utime and tms_cutime fields returned by the times() function defined in the System Interfaces volume of POSIX.1-2008 for the process in which utility is executed.
  3. The System CPU time, equivalent to the sum of the tms_stime and tms_cstime fields returned by the times() function for the process in which utility is executed.

To get information about resource utilization during the execution of the command date type:
$ /usr/bin/time -l date
Sample outputs:

Tue Dec  8 15:45:17 IST 2015
        0.00 real         0.00 user         0.00 sys
    696320  maximum resident set size
         0  average shared memory size
         0  average unshared data size
         0  average unshared stack size
       182  page reclaims
         0  page faults
         0  swaps
         0  block input operations
         0  block output operations
         0  messages sent
         0  messages received
         0  signals received
         0  voluntary context switches
        11  involuntary context switches

Examples and usage: How to summarize detailed system resource usage for given command on a Linux or Unix