UC San Diego SearchMenu

Timing commands and interpreting the statistics

Revised: October 2003.

The cshell has a built-in facility to time commands. It is described in "man csh" as follows:

time [command]
  Executes command (which must be  a  simple  command,
  not  an  alias,  a  pipeline,  a  command  list or a
  parenthesized command list) and prints a  time  sum-
  mary  as  described  under  the  time  variable.  If
  necessary, an extra shell is created  to  print  the
  time  statistic when the command completes.  Without
  command, prints a time summary for the current shell
  and its children.
       

Example (1):

time a.out

A second technique for timing commands is to set the shell variable "time" to some number of seconds (see example 2). The shell will then report statistics for any command which takes more than this number of cpu seconds. Most accounts set the "time" variable in their .login file.

Example (2):

   set time=3
        a.out
       

There is also a separate utility called "time" which is described by "man time". To use it, one must circumvent the time command built into the cshell by specifying the full path to the utility. On most systems, the full path is /usr/bin/time ; if it is not located there, use the "locate" command to find it:

locate time | grep /time$

Example (3) demonstrates how to use the 'time' utility:

/usr/bin/time a.out

Interpreting the Statistics

The statistics reported will look like this:

0.7u 2.3s 0:25 12% 27+133k 21+6io 3pf+0w

This example indicates that the command used 0.7 seconds of processor time in "user" mode and 2.3 seconds of processor time in "system" mode. On most systems the user is charged for the total of these two at the rate indicated for cputime in "help rates".

The elapsed time was 25 seconds (0:25); the command used 12% of the available processor cycles during the elapsed time. There was an average memory usage of 27k bytes of program space and 133k bytes of data space over the cpu time involved (27+133k); the program did 21 disk reads and six disk writes (21+6io), and took three page faults and was not swapped (3pf+0w).