time(1)
Name
time − time a command
Syntax
time command
Description
The given command is executed; after it is complete, time prints the elapsed time during the command, the time spent in the system, and the time spent in execution of the command. Times are reported in seconds.
The times are printed on the diagnostic output stream.
The time is built in to csh(,), using a different output format.
The time command can be used to cause a command to be timed no matter how much CPU time it takes. Thus
% time cp /etc/rc /usr/bill/rc
0.0u 0.1s 0:01 8% 2+1k 3+2io 1pf+0w
% time wc /etc/rc /usr/bill/rc
52 178 1347 /etc/rc
52 178 1347 /usr/bill/rc
104 356 2694 total
0.1u 0.1s 0:00 13% 3+3k 5+3io 7pf+0w
%
indicates that the cp command used a negligible amount of user time (u) and about 1/10th of a system time (s); the elapsed time was 1 second (0:01), there was an average memory usage of 2k bytes of program space and 1k bytes of data space over the cpu time involved (2+1k); the program did three disk reads and two disk writes (3+2io), and took one page fault and was not swapped (1pf+0w). The word count command wc on the other hand used 0.1 seconds of user time and 0.1 seconds of system time in less than a second of elapsed time. The percentage ‘13%’ indicates that over the period when it was active the command wc used an average of 13 percent of the available CPU cycles of the machine.
Restrictions
Elapsed time is accurate to the second, while the CPU times are measured to the 100th second. Thus the sum of the CPU times can be up to a second larger than the elapsed time.
The time is a built-in command to csh(,), with a much different syntax. This command is available as /bin/time to csh users.