Previous | Table of Contents | Next |
DESCRIPTION
The external timex command reports the time it takes to execute a command. It reports the elapsed wall clock time, the user time, and the system time. It can also be used to report accounting information. By using the timex command you can:
The time command is a pre-System V Release 3.0 utility that does not have any options. It only returns the elapsed wall clock, user, and system times for execution.
|
BSD (Berkeley) |
---|
The BSD version of UNIX does not support the timex command. There are two time commands available on BSD. One resides in /bin/time, the other is a C shell internal command. To execute the /bin/time you must specify the entire path if you are using the csh . If you are in a Bourne shell you do not have to specify the entire path. |
|
C Shell |
---|
The C shell supports an internal time command. Refer to Module 137 on time/times for further information. |
|
COMMAND FORMAT
Following is the general format of the timex and time command.
timex [ -ops ] command time command
| |
C Shell | |
---|---|
From within the csh you must specify the entire path to run the Berkeley time command instead of the csh time command. | |
/bin/time command | |
|
Options
The following list describes the options and their arguments that may be used to control how timex functions. Process accounting has to be running for some of the following commands to work properly.
-o | Reports the total number of blocks read and written by the command and all child processes. | |
-p | Report accounting records for the command and all child processes. The -p option has several suboptions to control which accounting records are reported . The suboptions are: | |
-f | Report the system exit status in the output and the exec /fork flag. | |
-h | Report the hog factor (CPU time/elapsed time). This is the fraction of total CPU time used by command . | |
-k | Report total kcore minutes, instead of memory size used. | |
-m | Report the mean core size. This is the normal reported output. | |
-r | Report CPU factor (user time/(system time + user time)). | |
-t | Report the number of blocks read and written and the system and CPU times. | |
-s | Report all system activity during the execution of command . All data items in the sar report are displayed. The sar command exists on most System V systems. It is the System Activity Report generator. It is not considered a user command, rather an administrative command. |
Arguments
The following argument may be passed to the timex command.
command | A UNIX command. Any executable program with options and arguments if they exist. |
DIAGNOSTICS AND BUGS
The timex command may report confusing results since it may include statistics for a background process executing with the same user ID, terminal ID, and execution window.
RELATED COMMANDS
Refer to the times command described in Module 139.
RELATED FILES
The timex command reads accounting information from the accounting file /usr/adm/pacct if the -p option is specified.
APPLICATIONS
The timex command is useful in timing the execution of commands. It is a necessary command if you are working on minimizing the execution time of a program. It can be used to track how much resources a process uses. It is sometimes added to the passwd file to time each user s login shell. Thus when you log out you will receive a report of statistics on your login session.
TYPICAL OPERATION
In this activity you use the timex command to time the execution of a UNIX utility. Begin at the shell prompt.
cj> timex bc <<! 2 ^ 9999 !
| |
C Shell | |
---|---|
cj> /bin/time bc <<! 2 ^ 9999 ! | |
|
Previous | Table of Contents | Next |