home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / t / time14.zip / time-1.4 / time.info (.txt) < prev    next >
GNU Info File  |  1992-10-28  |  11KB  |  202 lines

  1. This is Info file time.info, produced by Makeinfo-1.49 from the input
  2. file /home/gd/gnu/time/time.texinfo.
  3.    This file documents the the GNU `time' command for running programs
  4. and summarizing the system resources they use.
  5.    Copyright (C) 1989, 1991 Free Software Foundation, Inc.
  6.    Permission is granted to make and distribute verbatim copies of this
  7. manual provided the copyright notice and this permission notice are
  8. preserved on all copies.
  9.    Permission is granted to copy and distribute modified versions of
  10. this manual under the conditions for verbatim copying, provided that
  11. the entire resulting derived work is distributed under the terms of a
  12. permission notice identical to this one.
  13.    Permission is granted to copy and distribute translations of this
  14. manual into another language, under the above conditions for modified
  15. versions, except that this permission notice may be stated in a
  16. translation approved by the Foundation.
  17. File: time.info,  Node: Top,  Prev: (dir),  Up: (dir)
  18. `time': Measuring Program Resource Usage
  19. ****************************************
  20.    The `time' command runs another program, then displays information
  21. about the resources used by that program, collected by the system while
  22. the program was running.  You can select which information is reported
  23. and the format in which it is shown (*note Format::.), or have `time'
  24. save the information in a file instead of display it on the screen
  25. (*note Invoking time::.).
  26.    The format of the `time' command is:
  27.      time [-apvV] [-f FORMAT] [-o FILE] [--append] [--portability] [--verbose]
  28.      [--format=FORMAT] [--output-file=FILE] [--version]
  29.      COMMAND [ARG...]
  30.    Here is an example of using `time' to measure the time and other
  31. resources used by running the program `a.out':
  32.      time a.out
  33. * Menu:
  34. * Invoking time::    Running the `time' command, and its options.
  35. * Format::        Selecting the information reported by `time'.
  36. * Examples::        Examples of using `time'.
  37. * Accuracy::        Limitations on the accuracy of `time' output.
  38. File: time.info,  Node: Invoking time,  Next: Format,  Up: Top
  39. Using the `time' command
  40. ========================
  41.    The format of the `time' command is:
  42.      time [-apvV] [-f FORMAT] [-o FILE] [--append] [--portability] [--verbose]
  43.      [--format=FORMAT] [--output-file=FILE] [--version]
  44.      COMMAND [ARG...]
  45.    `time' first runs the program COMMAND.  When COMMAND finishes,
  46. `time' displays information about resources used by COMMAND, on the
  47. standard error output by default.  If COMMAND exits with non-zero
  48. status, `time' displays a warning message and the exit status.
  49.    `time' determines which information to display about the resources
  50. used by the COMMAND from a "format string" (*note Format::.). If no
  51. format is specified on the command line, but the `TIME' environment
  52. variable is set, its value is used as the format. Otherwise, a default
  53. format built into `time' is used (*note Format::.).
  54.    Options to `time' must appear on the command line before COMMAND. 
  55. Anything on the command line after COMMAND is passed as arguments to
  56. COMMAND.
  57.    The long-named options can be introduced with `+' as well as `--',
  58. for compatibility with previous releases.  Eventually support for `+'
  59. will be removed, because it is incompatible with the POSIX.2 standard.
  60. `-o FILE'
  61. `--output-file=FILE'
  62.      Write the resource usage statistics to FILE instead of to the
  63.      standard error stream.  By default, this *overwrites* the file,
  64.      destroying the file's previous contents.  This option is useful for
  65.      collecting information on interactive programs and programs that
  66.      produce output on the standard error stream.
  67. `--append'
  68.      *Append* the resource usage information to the output file instead
  69.      of overwriting it.  This option is only useful with the `-o' or
  70.      `--output-file' option.
  71. `-f FORMAT'
  72. `--format=FORMAT'
  73.      Use FORMAT as the format string that controls the output of `time'.
  74. `--portability'
  75.      Use the following format string, for conformance with POSIX 1003.2:
  76.           real %e
  77.           user %U
  78.           sys %S
  79. `--verbose'
  80.      Use the built-in verbose format (different from the built-in
  81.      default format), which displays every available piece of
  82.      information on the program's resource usage, on its own line with
  83.      an English description of its meaning.
  84. `--version'
  85.      Print the version number of `time'.
  86. File: time.info,  Node: Format,  Next: Examples,  Prev: Invoking time,  Up: Top
  87. Formatting The Output
  88. =====================
  89.    The "format string" controls the contents of the `time' output. The
  90. format string can be set using the `-f' or `--format' options, or a
  91. built-in verbose format can be selected using the `-v' or `--verbose'
  92. options; if they are not given, but the `TIME' environment variable is
  93. set, its value is used as the format string.  Otherwise, a built-in
  94. default format is used.  The default format is:
  95.      %Uuser %Ssystem %Eelapsed %PCPU (%Xtext+%Ddata %Mmax)k
  96.      %Iinputs+%Ooutputs (%Fmajor+%Rminor)pagefaults %Wswaps
  97.    The format string usually consists of "resource specifiers"
  98. interspersed with plain text.  A percent sign (`%') in the format
  99. string causes the following character to be interpreted as a resource
  100. specifier, which is similar to the formatting characters in the C
  101. `printf' function.
  102.    A backslash (`\') introduces a "backslash escape", which is
  103. translated into a single printing character upon output.  `\t' outputs
  104. a tab character, `\n' outputs a newline, and `\\' outputs a backslash. 
  105. A backslash followed by any other character outputs a question mark
  106. (`?') followed by a backslash, to indicate that an invalid backslash
  107. escape was given.
  108.    Other text in the format string is copied verbatim to the output.
  109. `time' always prints a newline after printing the resource usage
  110. information, so normally format strings do not end with a newline
  111. character (or `\n').
  112.    There are many resource specifications.  Not all resources are
  113. measured by all versions of Unix, so some of the values might be
  114. reported as 0. Any character following a percent sign that is not
  115. listed in the table below causes a question mark (`?') to be output,
  116. followed by that character, to indicate that an invalid resource
  117. specifier was given.
  118. The resource specification characters are:
  119.      A literal `%'.
  120.      The name and command line arguments of the command being timed.
  121.      The average size of the process's unshared data area, in Kilobytes.
  122.      The elapsed real (wall clock) time used by the process, in
  123.      [hours:]minutes:seconds.microseconds.
  124.      Number of major, or I/O-requiring, page faults that occurred while
  125.      the process was running.  These are faults where the page has
  126.      actually migrated out of primary memory.
  127.      Number of file system inputs by the process.
  128.      The average total memory usage of the process, in Kilobytes.
  129.      The maximum resident set size of the process during its lifetime,
  130.      in Kilobytes.
  131.      Number of file system outputs by the process.
  132.      The percentage of the CPU that this job got.  This is just user +
  133.      system times divied by the total running time.
  134.      Number of minor, or recoverable, page faults.  These are pages
  135.      that are not valid (so they fault) but which have not yet been
  136.      claimed by other virtual pages.  Thus the data in the page is
  137.      still valid but the system tables must be updated.
  138.      Total number of CPU-seconds used by the system on behalf of the
  139.      process (in kernel mode), in seconds:microseconds.
  140.      Total number of CPU-seconds that the process used directly (in user
  141.      mode), in seconds:microseconds.
  142.      Number of times the process was swapped out of main memory.
  143.      Average amount of shared text in the process, in Kilobytes.
  144.      The system's page size, in bytes.  This is a per-system constant,
  145.      but varies between systems.
  146.      Number of times the process was context-switched involuntarily
  147.      (because the time slice expired).
  148.      The elapsed real (wall clock) time used by the process, in
  149.      seconds.microseconds.
  150.      Number of signals delivered to the process.
  151.      The average unshared stack size of the process, in Kilobytes.
  152.      Number of socket messages received by the process.
  153.      Number of socket messages sent by the process.
  154.      The average resident set size of the process, in Kilobytes.
  155.      Number of times that the program was context-swapped voluntarily,
  156.      for instance while waiting for an I/O operation to complete.
  157.      The exit status of the process.
  158.    The resource specification characters are a superset of those
  159. recognized by the `tcsh' builtin `time' command.
  160. File: time.info,  Node: Examples,  Next: Accuracy,  Prev: Format,  Up: Top
  161. Examples
  162. ========
  163.    These examples assume that your command interpreter is `bash'.
  164. To run the command `wc /etc/hosts' and show the default information:
  165.      time wc /etc/hosts
  166. To run the command `ls -Fs' and show just the user, system, and total
  167. time:
  168.      time -f "\t%E real,\t%U user,\t%S sys" ls -Fs
  169. To edit the file BORK and have `time' append the elapsed time and
  170. number of signals to the file `log', reading the format string from the
  171. environment variable `TIME':
  172.      export TIME="\t%E,\t%k"
  173.      time -a -o log emacs bork
  174. File: time.info,  Node: Accuracy,  Prev: Examples,  Up: Top
  175. Accuracy
  176. ========
  177.    The elapsed time is not collected atomically with the execution of
  178. the program; as a result, in bizarre circumstances (if the `time'
  179. command gets stopped or swapped out in between when the program being
  180. timed exits and when `time' calculates how long it took to run), it
  181. could be much larger than the actual execution time.
  182.    When the running time of a command is very nearly zero, some values
  183. (e.g., the percentage of CPU used) may be reported as either zero (which
  184. is wrong) or a question mark.
  185.    Most information shown by `time' is derived from the `wait3' system
  186. call.  The numbers are only as good as those returned by `wait3'.  On
  187. systems that do not have a `wait3' call that returns status
  188. information, the `times' system call is used instead.  However, it
  189. provides much less information than `wait3', so on those systems `time'
  190. reports the majority of the resources as zero.
  191.    The `%I' and `%O' values are allegedly only "real" input and output
  192. and do not include those supplied by caching devices.  The meaning of
  193. "real" I/O reported by `%I' and `%O' may be muddled for workstations,
  194. especially diskless ones.
  195. Tag Table:
  196. Node: Top
  197. Node: Invoking time
  198. Node: Format
  199. Node: Examples
  200. Node: Accuracy
  201. End Tag Table
  202.