TIME(1) TIME(1)
time - time a command
time [ -f format | -l | -p ] command
The command is executed; after it exits, time prints resource usage
statistics to standard error. By default, this report includes the
elapsed time the command spent running, the CPU time spent in execution
of the command its reaped children, and the CPU time spent executing
system code by the command and its reaped children. Times are reported
in seconds.
time may be directed to produce other resource usage reports via command
line options. Additionally, the environment variable TIME may be used to
establish a default report format. See below for a description of how
the contents of this report format specification are interpreted.
-f format
Specify a resource usage report format. See below for a description
of how the contents of this string are interpreted.
-l Use a long resource usage report that covers all resource usage
statistics that are collected.
-p Use the standard default resource usage report format:
real elapsed time
user user CPU time
sys system CPU time
This is useful when the TIME environment variable has been set to
establish a different default resource usage report format.
RESOURCE USAGE REPORT FORMAT SPECIFICATION [Toc] [Back] time may be directed to produce a customized resource usage report format
either via the -f format command line option or the TIME environment
variable. In both cases the specified string is scanned for printf(3)-
like percent ("%") escape sequences. These sequences cause various
resource usage statistics to be output. Additionally several backslash
("\") escapes are also provided to help in outputting special characters.
All other non-escape characters are output as is. The set of escape
sequences recognized and their interpretations are:
\\ A backslash "\".
\n A newline. Note: if the last character output by the format string
is not a newline, one will be automatically appended.
Page 1
TIME(1) TIME(1)
\r A carriage return.
\t A tab.
\nnn The character corresponding to the octal number nnn which may be up
to three digits.
%% A percent sign "%".
%E The elapsed time.
%U The user CPU time for command and all of its children which were
reaped by command. (A child is reaped by calling one of the wait(2)
system calls.)
%S The system CPU time for command and all of its children which were
reaped
%P The percent CPU utilization followed by a percent sign "%". This is
calculated as (%U+%S)/%E*100. Note that this percentage can be
greater that 100% on multiprocessor systems. This can happen
because %U and %S include all the CPU time accumulated by command
and its reaped children. Since those children can execute in
parallel on an MP system, CPU time can accumulate faster than
elapsed time ...
%R The number of page faults that resulted in a page being reclaimed
from the page cache.
%F The number of page faults that resulted in a page being read from
disk.
%V The sum of %R and %F.
%w The number of voluntary context switches. These result from
explicit yields via calls to sleep(2), sginap(2), etc. and from
contention on a resource. High voluntary context switches and large
amounts of idle time often indicate an MP resource contention
problem.
%c The number of involuntary context switches. These result from a
process being switched out at the end of its CPU time slice or being
preempted by a higher priority process.
%W The number of times the process was swapped. Non-zero values here
indicate that the system memory is probably desperately
oversubscribed.
%C The sum of %w, %c, and %W.
Page 2
TIME(1) TIME(1)
%I The number of disk input operations that were performed for the
process. Note that not all read(2) calls result in disk input
operations. If the requested data is found in the system buffer
cache, no disk input operation will be necessary.
%O The number of disk output operations that were performed for the
process. Note that this number is somewhat fuzzy since write(2)
calls are performed asynchronously by copying the requested output
data into the system buffer cache and scheduling the actual output
operation to occur at a later time. If the process exits before the
actual output operation, it won't be charged against the process.
%? The sum of %I and %O.
%k The number of signals received by the process.
If the command is invoked, the exit status of time will be the exit
status of command. time will exit with an exit status of 1-125 if an
error occurred in the time command itself. An exit status of 126 will be
returned if the command specified was found but could not be invoked. If
the command could not be found, the exit status will be 127.
TIME Used to establish a default resource usage report format. The -p
option may be used to force the built in default.
Users of csh(1), tcsh(1), and ksh(1) (and most other shells) beware:
these shells have builtin time commands which perform the same function
as time(1) but print the results in a different format. Also note that
the time commands in csh and tcsh have similar, but not identical output
formatting capability.
Note that timing shell pipe lines may not produce the results that you
think they should. In particular, the Bourne and Korn shells both return
as soon as the last command in a pipe line terminates. For instance,
note that in the second example below, /bin/time outputs a real time of
approximately 5 seconds even though the first command in the pipe line
won't terminate for another 5 seconds.
% /bin/time /bin/sh -c 'sleep 5 | sleep 10'
real 10.100
user 0.010
sys 0.040
% /bin/time /bin/sh -c 'sleep 10 | sleep 5'
real 5.060
user 0.010
sys 0.040
Page 3
TIME(1) TIME(1)
csh(1), tcsh(1), ksh(1), getrusage(2), perfex(1), ssrun(1)*
* The ssrun(1) command is part of the SpeedShop image in the IRIXTM
Development Option.
PPPPaaaaggggeeee 4444 [ Back ]
|