Module 136 timetimex

Previous Table of Contents Next


Module 136
time/timex

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:

   Report execution time of a command (elapsed, user, and system).
   Report total number of blocks read and written.
   Report total system activity during command execution.
   Report various accounting information.

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.

1.    Type the following lines, pressing Return at the end of each line. After you finish the last line wait for the result. Depending on your computer s speed it may take a few seconds or minutes.
 cj> timex bc <<!   2 ^ 9999   ! 

The output is about two 24 line screens of numbers . The amount of time it took your computer to calculate 2 to the 9999th power will also be displayed after the number. (The fastest I ve seen is 17 seconds on a Mips workstation, unless you include a vectorized calculation by a Convex or Cray).

C Shell
cj> /bin/time bc <<!
2 ^ 9999
!

2.     Turn to Module 137 to continue the learning sequence.


Previous Table of Contents Next

Copyright Wordware Publishing, Inc.


Illustrated UNIX System V
Illustrated Unix System V/Bsd
ISBN: 1556221878
EAN: 2147483647
Year: N/A
Pages: 144
Authors: Robert Felps

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net