Two commands, time and /bin/time , provide simple timings. Their information is highly accurate, because no profiling overhead distorts the program's performance. Neither program provides any analysis on the routine or trace level. They report the total execution time, some other global statistics, and nothing more. You can use them on any program.
time and /bin/time differ primarily in that time is built into the C shell. Therefore, it cannot be used in Bourne shell scripts or in makefiles. It also cannot be used if you prefer the Bourne shell ( sh ). /bin/time is an independent executable file and therefore can be used in any situation. To get a simple program timing, enter either time or /bin/time , followed by the command you would normally use to execute the program. For example, to time a program named analyze , enter the following command:
This indicates that the program spent 9.0 seconds on behalf of the user (user time), 6.7 seconds on behalf of the system (system time, or time spent executing UNIX kernel routines on the user's behalf), and a total of 30 seconds elapsed time. Elapsed time is the wall clock time from the moment you enter the command until it terminates, including time spent waiting for other users, I/O time, etc.
By definition, the elapsed time is greater than your total CPU time and can even be several times larger. You can set programs to be timed automatically (without typing time first) or change the output format by setting the csh.
The example above shows the CPU time as a percentage of the elapsed time (18 percent). The remaining data report virtual memory management and I/O statistics. The meaning varies, depending on your shell; check your online csh manual page or article 39.3 .
In this example, under SunOS 4.1.1, the other fields show the amount of
shared memory used, the amount
of nonshared memory used (
/bin/time reports only the real time (elapsed time), user time, and system time. For example:
[If you use the Bourne shell, you can just type
Article 39.5 has more about the terms used in this article.
- from O'Reilly & Associates' UNIX for FORTRAN Programmers , Chapter 8