home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-bin / info / time.info < prev    next >
Encoding:
GNU Info File  |  1996-10-12  |  14.8 KB  |  479 lines

  1. This is Info file time.info, produced by Makeinfo-1.64 from the input
  2. file /ade-src/fsf/time/time.texi.
  3.  
  4.    This file documents the the GNU `time' command for running programs
  5. and summarizing the system resources they use.
  6.  
  7.    Copyright (C) 1991, 92, 93, 96 Free Software Foundation, Inc.
  8.  
  9.    Permission is granted to make and distribute verbatim copies of this
  10. manual provided the copyright notice and this permission notice are
  11. preserved on all copies.
  12.  
  13.    Permission is granted to copy and distribute modified versions of
  14. this manual under the conditions for verbatim copying, provided that
  15. the entire resulting derived work is distributed under the terms of a
  16. permission notice identical to this one.
  17.  
  18.    Permission is granted to copy and distribute translations of this
  19. manual into another language, under the above conditions for modified
  20. versions, except that this permission notice may be stated in a
  21. translation approved by the Foundation.
  22.  
  23. 
  24. File: time.info,  Node: Top,  Prev: (dir),  Up: (dir)
  25.  
  26.    This file documents the the GNU `time' command for running programs
  27. and summarizing the system resources they use.  This is edition 1.7,
  28. for version 1.7.
  29.  
  30. * Menu:
  31.  
  32. * Resource Measurement::  Measuring program resource use.
  33.  
  34.  -- The Detailed Node Listing --
  35.  
  36. Measuring Program Resource Use
  37.  
  38. * Setting Format::      Selecting the information reported by `time'.
  39. * Format String::    The information `time' can report.
  40. * Redirecting::         Writing the information to a file.
  41. * Examples::        Examples of using `time'.
  42. * Accuracy::        Limitations on the accuracy of `time' output.
  43. * Invoking time::    Summary of the options to the `time' command.
  44.  
  45. The Format String
  46.  
  47. * Time Resources::
  48. * Memory Resources::
  49. * I/O Resources::
  50. * Command Info::
  51.  
  52. 
  53. File: time.info,  Node: Resource Measurement,  Up: Top
  54.  
  55. Measuring Program Resource Use
  56. ******************************
  57.  
  58.    The `time' command runs another program, then displays information
  59. about the resources used by that program, collected by the system while
  60. the program was running.  You can select which information is reported
  61. and the format in which it is shown (*note Setting Format::.), or have
  62. `time' save the information in a file instead of displaying it on the
  63. screen (*note Redirecting::.).
  64.  
  65.    The resources that `time' can report on fall into the general
  66. categories of time, memory, and I/O and IPC calls.  Some systems do not
  67. provide much information about program resource use; `time' reports
  68. unavailable information as zero values (*note Accuracy::.).
  69.  
  70.    The format of the `time' command is:
  71.  
  72.      time [option...] COMMAND [ARG...]
  73.  
  74.    `time' runs the program COMMAND, with any given arguments ARG....
  75. When COMMAND finishes, `time' displays information about resources used
  76. by COMMAND.
  77.  
  78.    Here is an example of using `time' to measure the time and other
  79. resources used by running the program `grep':
  80.  
  81.      eg$ time grep nobody /etc/aliases
  82.      nobody:/dev/null
  83.      etc-files:nobody
  84.      misc-group:nobody
  85.      0.07user 0.50system 0:06.69elapsed 8%CPU (0avgtext+489avgdata 324maxresident)k
  86.      46inputs+7outputs (43major+251minor)pagefaults 0swaps
  87.  
  88.    Mail suggestions and bug reports for GNU `time' to
  89. `bug-gnu-utils@prep.ai.mit.edu'.  Please include the version of `time',
  90. which you can get by running `time --version', and the operating system
  91. and C compiler you used.
  92.  
  93. * Menu:
  94.  
  95. * Setting Format::      Selecting the information reported by `time'.
  96. * Format String::    The information `time' can report.
  97. * Redirecting::         Writing the information to a file.
  98. * Examples::        Examples of using `time'.
  99. * Accuracy::        Limitations on the accuracy of `time' output.
  100. * Invoking time::    Summary of the options to the `time' command.
  101.  
  102. 
  103. File: time.info,  Node: Setting Format,  Next: Format String,  Up: Resource Measurement
  104.  
  105. Setting the Output Format
  106. =========================
  107.  
  108.    `time' uses a "format string" to determine which information to
  109. display about the resources used by the command it runs.  *Note Format
  110. String::, for the interpretation of the format string contents.
  111.  
  112.    You can specify a format string with the command line options listed
  113. below.  If no format is specified on the command line, but the `TIME'
  114. environment variable is set, its value is used as the format string.
  115. Otherwise, the default format built into `time' is used:
  116.  
  117.      %Uuser %Ssystem %Eelapsed %PCPU (%Xtext+%Ddata %Mmax)k
  118.      %Iinputs+%Ooutputs (%Fmajor+%Rminor)pagefaults %Wswaps
  119.  
  120.    The command line options to set the format are:
  121.  
  122. `-f FORMAT'
  123. `--format=FORMAT'
  124.      Use FORMAT as the format string.
  125.  
  126. `-p'
  127. `--portability'
  128.      Use the following format string, for conformance with POSIX
  129.      standard 1003.2:
  130.  
  131.           real %e
  132.           user %U
  133.           sys %S
  134.  
  135. `-v'
  136. `--verbose'
  137.      Use the built-in verbose format, which displays each available
  138.      piece of information on the program's resource use on its own
  139.      line, with an English description of its meaning.
  140.  
  141. 
  142. File: time.info,  Node: Format String,  Next: Redirecting,  Prev: Setting Format,  Up: Resource Measurement
  143.  
  144. The Format String
  145. =================
  146.  
  147.    The "format string" controls the contents of the `time' output.  It
  148. consists of "resource specifiers" and "escapes", interspersed with
  149. plain text.
  150.  
  151.    A backslash introduces an "escape", which is translated into a
  152. single printing character upon output.  The valid escapes are listed
  153. below.  An invalid escape is output as a question mark followed by a
  154. backslash.
  155.  
  156. `\t'
  157.      a tab character
  158.  
  159. `\n'
  160.      a newline
  161.  
  162. `\\'
  163.      a literal backslash
  164.  
  165.    `time' always prints a newline after printing the resource use
  166. information, so normally format strings do not end with a newline
  167. character (or `\n').
  168.  
  169.    A resource specifier consists of a percent sign followed by another
  170. character.  An invalid resource specifier is output as a question mark
  171. followed by the invalid character.  Use `%%' to output a literal
  172. percent sign.
  173.  
  174.    The resource specifiers, which are a superset of those recognized by
  175. the `tcsh' builtin `time' command, are listed below.  Not all resources
  176. are measured by all versions of Unix, so some of the values might be
  177. reported as zero (*note Accuracy::.).
  178.  
  179. * Menu:
  180.  
  181. * Time Resources::
  182. * Memory Resources::
  183. * I/O Resources::
  184. * Command Info::
  185.  
  186. 
  187. File: time.info,  Node: Time Resources,  Next: Memory Resources,  Up: Format String
  188.  
  189. Time Resources
  190. --------------
  191.  
  192. `E'
  193.      Elapsed real (wall clock) time used by the process, in
  194.      [hours:]minutes:seconds.
  195.  
  196. `e'
  197.      Elapsed real (wall clock) time used by the process, in seconds.
  198.  
  199. `S'
  200.      Total number of CPU-seconds used by the system on behalf of the
  201.      process (in kernel mode), in seconds.
  202.  
  203. `U'
  204.      Total number of CPU-seconds that the process used directly (in user
  205.      mode), in seconds.
  206.  
  207. `P'
  208.      Percentage of the CPU that this job got.  This is just user +
  209.      system times divied by the total running time.
  210.  
  211. 
  212. File: time.info,  Node: Memory Resources,  Next: I/O Resources,  Prev: Time Resources,  Up: Format String
  213.  
  214. Memory Resources
  215. ----------------
  216.  
  217. `M'
  218.      Maximum resident set size of the process during its lifetime, in
  219.      Kilobytes.
  220.  
  221. `t'
  222.      Average resident set size of the process, in Kilobytes.
  223.  
  224. `K'
  225.      Average total (data+stack+text) memory use of the process, in
  226.      Kilobytes.
  227.  
  228. `D'
  229.      Average size of the process's unshared data area, in Kilobytes.
  230.  
  231. `p'
  232.      Average size of the process's unshared stack, in Kilobytes.
  233.  
  234. `X'
  235.      Average size of the process's shared text, in Kilobytes.
  236.  
  237. `Z'
  238.      System's page size, in bytes.  This is a per-system constant, but
  239.      varies between systems.
  240.  
  241. 
  242. File: time.info,  Node: I/O Resources,  Next: Command Info,  Prev: Memory Resources,  Up: Format String
  243.  
  244. I/O Resources
  245. -------------
  246.  
  247. `F'
  248.      Number of major, or I/O-requiring, page faults that occurred while
  249.      the process was running.  These are faults where the page has
  250.      actually migrated out of primary memory.
  251.  
  252. `R'
  253.      Number of minor, or recoverable, page faults.  These are pages
  254.      that are not valid (so they fault) but which have not yet been
  255.      claimed by other virtual pages.  Thus the data in the page is
  256.      still valid but the system tables must be updated.
  257.  
  258. `W'
  259.      Number of times the process was swapped out of main memory.
  260.  
  261. `c'
  262.      Number of times the process was context-switched involuntarily
  263.      (because the time slice expired).
  264.  
  265. `w'
  266.      Number of times that the program was context-switched voluntarily,
  267.      for instance while waiting for an I/O operation to complete.
  268.  
  269. `I'
  270.      Number of file system inputs by the process.
  271.  
  272. `O'
  273.      Number of file system outputs by the process.
  274.  
  275. `r'
  276.      Number of socket messages received by the process.
  277.  
  278. `s'
  279.      Number of socket messages sent by the process.
  280.  
  281. `k'
  282.      Number of signals delivered to the process.
  283.  
  284. 
  285. File: time.info,  Node: Command Info,  Prev: I/O Resources,  Up: Format String
  286.  
  287. Command Info
  288. ------------
  289.  
  290. `C'
  291.      Name and command line arguments of the command being timed.
  292.  
  293. `x'
  294.      Exit status of the command.
  295.  
  296. 
  297. File: time.info,  Node: Redirecting,  Next: Examples,  Prev: Format String,  Up: Resource Measurement
  298.  
  299. Redirecting Output
  300. ==================
  301.  
  302.    By default, `time' writes the resource use statistics to the
  303. standard error stream.  The options below make it write the statistics
  304. to a file instead.  Doing this can be useful if the program you're
  305. running writes to the standard error or you're running `time'
  306. noninteractively or in the background.
  307.  
  308. `-o FILE'
  309. `--output=FILE'
  310.      Write the resource use statistics to FILE.  By default, this
  311.      *overwrites* the file, destroying the file's previous contents.
  312.  
  313. `-a'
  314. `--append'
  315.      *Append* the resource use information to the output file instead
  316.      of overwriting it.  This option is only useful with the `-o' or
  317.      `--output' option.
  318.  
  319. 
  320. File: time.info,  Node: Examples,  Next: Accuracy,  Prev: Redirecting,  Up: Resource Measurement
  321.  
  322. Examples
  323. ========
  324.  
  325. Run the command `wc /etc/hosts' and show the default information:
  326.  
  327.      eg$ time wc /etc/hosts
  328.            35     111    1134 /etc/hosts
  329.      0.00user 0.01system 0:00.04elapsed 25%CPU (0avgtext+0avgdata 0maxresident)k
  330.      1inputs+1outputs (0major+0minor)pagefaults 0swaps
  331.  
  332. Run the command `ls -Fs' and show just the user, system, and wall-clock
  333. time:
  334.  
  335.      eg$ time -f "\t%E real,\t%U user,\t%S sys" ls -Fs
  336.      total 16
  337.      1 account/      1 db/           1 mail/         1 run/
  338.      1 backups/      1 emacs/        1 msgs/         1 rwho/
  339.      1 crash/        1 games/        1 preserve/     1 spool/
  340.      1 cron/         1 log/          1 quotas/       1 tmp/
  341.              0:00.03 real,   0.00 user,      0.01 sys
  342.  
  343. Edit the file `.bashrc' and have `time' append the elapsed time and
  344. number of signals to the file `log', reading the format string from the
  345. environment variable `TIME':
  346.  
  347.      eg$ export TIME="\t%E,\t%k" # If using bash or ksh
  348.      eg$ setenv TIME "\t%E,\t%k" # If using csh or tcsh
  349.      eg$ time -a -o log emacs .bashrc
  350.      eg$ cat log
  351.              0:16.55,        726
  352.  
  353. Run the command `sleep 4' and show all of the information about it
  354. verbosely:
  355.  
  356.      eg$ time -v sleep 4
  357.              Command being timed: "sleep 4"
  358.              User time (seconds): 0.00
  359.              System time (seconds): 0.05
  360.              Percent of CPU this job got: 1%
  361.              Elapsed (wall clock) time (h:mm:ss or m:ss): 0:04.26
  362.              Average shared text size (kbytes): 36
  363.              Average unshared data size (kbytes): 24
  364.              Average stack size (kbytes): 0
  365.              Average total size (kbytes): 60
  366.              Maximum resident set size (kbytes): 32
  367.              Average resident set size (kbytes): 24
  368.              Major (requiring I/O) page faults: 3
  369.              Minor (reclaiming a frame) page faults: 0
  370.              Voluntary context switches: 11
  371.              Involuntary context switches: 0
  372.              Swaps: 0
  373.              File system inputs: 3
  374.              File system outputs: 1
  375.              Socket messages sent: 0
  376.              Socket messages received: 0
  377.              Signals delivered: 1
  378.              Page size (bytes): 4096
  379.              Exit status: 0
  380.  
  381. 
  382. File: time.info,  Node: Accuracy,  Next: Invoking time,  Prev: Examples,  Up: Resource Measurement
  383.  
  384. Accuracy
  385. ========
  386.  
  387.    The elapsed time is not collected atomically with the execution of
  388. the program; as a result, in bizarre circumstances (if the `time'
  389. command gets stopped or swapped out in between when the program being
  390. timed exits and when `time' calculates how long it took to run), it
  391. could be much larger than the actual execution time.
  392.  
  393.    When the running time of a command is very nearly zero, some values
  394. (e.g., the percentage of CPU used) may be reported as either zero (which
  395. is wrong) or a question mark.
  396.  
  397.    Most information shown by `time' is derived from the `wait3' system
  398. call.  The numbers are only as good as those returned by `wait3'.  Many
  399. systems do not measure all of the resources that `time' can report on;
  400. those resources are reported as zero.  The systems that measure most or
  401. all of the resources are based on 4.2 or 4.3BSD.  Later BSD releases
  402. use different memory management code that measures fewer resources.
  403.  
  404.    On systems that do not have a `wait3' call that returns status
  405. information, the `times' system call is used instead.  It provides much
  406. less information than `wait3', so on those systems `time' reports most
  407. of the resources as zero.
  408.  
  409.    The `%I' and `%O' values are allegedly only "real" input and output
  410. and do not include those supplied by caching devices.  The meaning of
  411. "real" I/O reported by `%I' and `%O' may be muddled for workstations,
  412. especially diskless ones.
  413.  
  414. 
  415. File: time.info,  Node: Invoking time,  Prev: Accuracy,  Up: Resource Measurement
  416.  
  417. Running the `time' Command
  418. ==========================
  419.  
  420.    The format of the `time' command is:
  421.  
  422.      time [option...] COMMAND [ARG...]
  423.  
  424.    `time' runs the program COMMAND, with any given arguments ARG....
  425. When COMMAND finishes, `time' displays information about resources used
  426. by COMMAND (on the standard error output, by default).  If COMMAND
  427. exits with non-zero status or is terminated by a signal, `time'
  428. displays a warning message and the exit status or signal number.
  429.  
  430.    Options to `time' must appear on the command line before COMMAND.
  431. Anything on the command line after COMMAND is passed as arguments to
  432. COMMAND.
  433.  
  434. `-o FILE'
  435. `--output=FILE'
  436.      Write the resource use statistics to FILE.
  437.  
  438. `-a'
  439. `--append'
  440.      *Append* the resource use information to the output file instead
  441.      of overwriting it.
  442.  
  443. `-f FORMAT'
  444. `--format=FORMAT'
  445.      Use FORMAT as the format string.
  446.  
  447. `--help'
  448.      Print a summary of the command line options to `time' and exit.
  449.  
  450. `-p'
  451. `--portability'
  452.      Use the POSIX format.
  453.  
  454. `-v'
  455. `--verbose'
  456.      Use the built-in verbose format.
  457.  
  458. `-V'
  459. `--version'
  460.      Print the version number of `time' and exit.
  461.  
  462.  
  463. 
  464. Tag Table:
  465. Node: Top950
  466. Node: Resource Measurement1741
  467. Node: Setting Format3694
  468. Node: Format String4923
  469. Node: Time Resources6230
  470. Node: Memory Resources6860
  471. Node: I/O Resources7565
  472. Node: Command Info8763
  473. Node: Redirecting8980
  474. Node: Examples9770
  475. Node: Accuracy12080
  476. Node: Invoking time13602
  477. 
  478. End Tag Table
  479.