1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
<html>
<!-- Created on July, 21 2008 by texi2html 1.78 -->
<!--
Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
Karl Berry <karl@freefriends.org>
Olaf Bachmann <obachman@mathematik.uni-kl.de>
and many others.
Maintained by: Many creative people.
Send bugs and suggestions to <texi2html-bug@nongnu.org>
-->
<head>
<title>Measuring Program Resource Use</title>
<meta name="description" content="Measuring Program Resource Use">
<meta name="keywords" content="Measuring Program Resource Use">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="texi2html 1.78">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
pre.display {font-family: serif}
pre.format {font-family: serif}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: serif; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: serif; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.roman {font-family:serif; font-weight:normal;}
span.sansserif {font-family:sans-serif; font-weight:normal;}
ul.toc {list-style: none}
-->
</style>
</head>
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="Top"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[Index]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h1 class="settitle">Measuring Program Resource Use
</h1>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top"><a href="#SEC1">1. Measuring Program Resource Use</a></td><td> </td><td align="left" valign="top"> Measuring program resource use.
</td></tr>
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
--- The Detailed Node Listing ---
Measuring Program Resource Use
</pre></th></tr><tr><td align="left" valign="top"><a href="#SEC2">1.1 Setting the Output Format</a></td><td> </td><td align="left" valign="top"> Selecting the information reported by <code>time</code>.
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC3">1.2 The Format String</a></td><td> </td><td align="left" valign="top"> The information <code>time</code> can report.
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC8">1.3 Redirecting Output</a></td><td> </td><td align="left" valign="top"> Writing the information to a file.
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC9">1.4 Examples</a></td><td> </td><td align="left" valign="top"> Examples of using <code>time</code>.
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC10">1.5 Accuracy</a></td><td> </td><td align="left" valign="top"> Limitations on the accuracy of <code>time</code> output.
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC11">1.6 Running the <code>time</code> Command</a></td><td> </td><td align="left" valign="top"> Summary of the options to the <code>time</code> command.
</td></tr>
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
The Format String
</pre></th></tr><tr><td align="left" valign="top"><a href="#SEC4">1.2.1 Time Resources</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC5">1.2.2 Memory Resources</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC6">1.2.3 I/O Resources</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC7">1.2.4 Command Info</a></td><td> </td><td align="left" valign="top">
</td></tr>
</table>
<hr size="1">
<a name="Resource-Measurement"></a>
<a name="SEC1"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Top" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC2" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[ << ]</td>
<td valign="middle" align="left">[<a href="#Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[ >> ]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[Index]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h1 class="chapter"> 1. Measuring Program Resource Use </h1>
<p>The <code>time</code> command runs another program, then displays information
about the resources used by that program, collected by the system while
the program was running. You can select which information is reported
and the format in which it is shown (see section <a href="#SEC2">Setting the Output Format</a>), or have
<code>time</code> save the information in a file instead of displaying it on the
screen (see section <a href="#SEC8">Redirecting Output</a>).
</p>
<p>The resources that <code>time</code> can report on fall into the general
categories of time, memory, and I/O and IPC calls. Some systems do not
provide much information about program resource use; <code>time</code>
reports unavailable information as zero values (see section <a href="#SEC10">Accuracy</a>).
</p>
<p>The format of the <code>time</code> command is:
</p>
<table><tr><td> </td><td><pre class="example">time <span class="roman">[</span>option…<span class="roman">]</span> <var>command</var> <span class="roman">[</span><var>arg</var>…<span class="roman">]</span>
</pre></td></tr></table>
<a name="IDX1"></a>
<p><code>time</code> runs the program <var>command</var>, with any given arguments
<var>arg</var>…. When <var>command</var> finishes, <code>time</code> displays
information about resources used by <var>command</var>.
</p>
<p>Here is an example of using <code>time</code> to measure the time and other
resources used by running the program <code>grep</code>:
</p>
<table><tr><td> </td><td><pre class="example">eg$ time grep nobody /etc/aliases
nobody:/dev/null
etc-files:nobody
misc-group:nobody
0.07user 0.50system 0:06.69elapsed 8%CPU (0avgtext+489avgdata 324maxresident)k
46inputs+7outputs (43major+251minor)pagefaults 0swaps
</pre></td></tr></table>
<p>Mail suggestions and bug reports for GNU <code>time</code> to
<code>bug-gnu-utils@prep.ai.mit.edu</code>. Please include the version of
<code>time</code>, which you can get by running ‘<samp>time --version</samp>’, and the
operating system and C compiler you used.
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top"><a href="#SEC2">1.1 Setting the Output Format</a></td><td> </td><td align="left" valign="top"> Selecting the information reported by <code>time</code>.
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC3">1.2 The Format String</a></td><td> </td><td align="left" valign="top"> The information <code>time</code> can report.
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC8">1.3 Redirecting Output</a></td><td> </td><td align="left" valign="top"> Writing the information to a file.
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC9">1.4 Examples</a></td><td> </td><td align="left" valign="top"> Examples of using <code>time</code>.
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC10">1.5 Accuracy</a></td><td> </td><td align="left" valign="top"> Limitations on the accuracy of <code>time</code> output.
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC11">1.6 Running the <code>time</code> Command</a></td><td> </td><td align="left" valign="top"> Summary of the options to the <code>time</code> command.
</td></tr>
</table>
<hr size="6">
<a name="Setting-Format"></a>
<a name="SEC2"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC1" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC3" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC1" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC1" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[ >> ]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[Index]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 1.1 Setting the Output Format </h2>
<p><code>time</code> uses a <em>format string</em> to determine which information to
display about the resources used by the command it runs. See section <a href="#SEC3">The Format String</a>, for the interpretation of the format string contents.
</p>
<p>You can specify a format string with the command line options listed
below. If no format is specified on the command line, but the
<code>TIME</code> environment variable is set, its value is used as the format
string. Otherwise, the default format built into <code>time</code> is used:
</p>
<table><tr><td> </td><td><pre class="example">%Uuser %Ssystem %Eelapsed %PCPU (%Xtext+%Ddata %Mmax)k
%Iinputs+%Ooutputs (%Fmajor+%Rminor)pagefaults %Wswaps
</pre></td></tr></table>
<p>The command line options to set the format are:
</p>
<dl compact="compact">
<dt> <code>-f <var>format</var></code></dt>
<dt> <code>--format=<var>format</var></code></dt>
<dd><p>Use <var>format</var> as the format string.
</p>
</dd>
<dt> <code>-p</code></dt>
<dt> <code>--portability</code></dt>
<dd><p>Use the following format string, for conformance with POSIX standard
1003.2:
</p>
<table><tr><td> </td><td><pre class="example">real %e
user %U
sys %S
</pre></td></tr></table>
</dd>
<dt> <code>-q</code></dt>
<dt> <code>--quiet</code></dt>
<dd><p>Suppress non-zero error code from the executed program.
</p>
</dd>
<dt> <code>-v</code></dt>
<dt> <code>--verbose</code></dt>
<dd><a name="IDX2"></a>
<p>Use the built-in verbose format, which displays each available piece of
information on the program's resource use on its own line, with an
English description of its meaning.
</p></dd>
</dl>
<hr size="6">
<a name="Format-String"></a>
<a name="SEC3"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC2" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC4" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC1" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC1" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[ >> ]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[Index]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 1.2 The Format String </h2>
<p>The <em>format string</em> controls the contents of the <code>time</code> output.
It consists of <em>resource specifiers</em> and <em>escapes</em>, interspersed
with plain text.
</p>
<p>A backslash introduces an <em>escape</em>, which is translated
into a single printing character upon output. The valid escapes are
listed below. An invalid escape is output as a question mark followed
by a backslash.
</p>
<dl compact="compact">
<dt> <code>\t</code></dt>
<dd><p>a tab character
</p>
</dd>
<dt> <code>\n</code></dt>
<dd><p>a newline
</p>
</dd>
<dt> <code>\\</code></dt>
<dd><p>a literal backslash
</p></dd>
</dl>
<p><code>time</code> always prints a newline after printing the resource use
information, so normally format strings do not end with a newline
character (or ‘<samp>\n</samp>’).
</p>
<p>A resource specifier consists of a percent sign followed by another
character. An invalid resource specifier is output as a question mark
followed by the invalid character. Use ‘<samp>%%</samp>’ to output a literal
percent sign.
</p>
<p>The resource specifiers, which are a superset of those recognized by the
<code>tcsh</code> builtin <code>time</code> command, are listed below. Not all
resources are measured by all versions of Unix, so some of the values
might be reported as zero (see section <a href="#SEC10">Accuracy</a>).
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top"><a href="#SEC4">1.2.1 Time Resources</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC5">1.2.2 Memory Resources</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC6">1.2.3 I/O Resources</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC7">1.2.4 Command Info</a></td><td> </td><td align="left" valign="top">
</td></tr>
</table>
<hr size="6">
<a name="Time-Resources"></a>
<a name="SEC4"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC3" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC5" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC1" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC3" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[ >> ]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[Index]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection"> 1.2.1 Time Resources </h3>
<dl compact="compact">
<dt> <code>E</code></dt>
<dd><p>Elapsed real (wall clock) time used by the process, in
[hours:]minutes:seconds.
</p>
</dd>
<dt> <code>e</code></dt>
<dd><p>Elapsed real (wall clock) time used by the process, in
seconds.
</p>
</dd>
<dt> <code>S</code></dt>
<dd><p>Total number of CPU-seconds used by the system on behalf of the process
(in kernel mode), in seconds.
</p>
</dd>
<dt> <code>U</code></dt>
<dd><p>Total number of CPU-seconds that the process used directly (in user
mode), in seconds.
</p>
</dd>
<dt> <code>P</code></dt>
<dd><p>Percentage of the CPU that this job got. This is just user + system
times divied by the total running time.
</p></dd>
</dl>
<hr size="6">
<a name="Memory-Resources"></a>
<a name="SEC5"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC4" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC6" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC1" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC3" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[ >> ]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[Index]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection"> 1.2.2 Memory Resources </h3>
<dl compact="compact">
<dt> <code>M</code></dt>
<dd><p>Maximum resident set size of the process during its lifetime, in
Kilobytes.
</p>
</dd>
<dt> <code>t</code></dt>
<dd><p>Average resident set size of the process, in Kilobytes.
</p>
</dd>
<dt> <code>K</code></dt>
<dd><p>Average total (data+stack+text) memory use of the process, in Kilobytes.
</p>
</dd>
<dt> <code>D</code></dt>
<dd><p>Average size of the process's unshared data area, in Kilobytes.
</p>
</dd>
<dt> <code>p</code></dt>
<dd><p>Average size of the process's unshared stack, in Kilobytes.
</p>
</dd>
<dt> <code>X</code></dt>
<dd><p>Average size of the process's shared text, in Kilobytes.
</p>
</dd>
<dt> <code>Z</code></dt>
<dd><p>System's page size, in bytes. This is a per-system constant, but
varies between systems.
</p></dd>
</dl>
<hr size="6">
<a name="I_002fO-Resources"></a>
<a name="SEC6"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC5" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC7" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC1" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC3" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[ >> ]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[Index]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection"> 1.2.3 I/O Resources </h3>
<dl compact="compact">
<dt> <code>F</code></dt>
<dd><p>Number of major, or I/O-requiring, page faults that occurred while the
process was running. These are faults where the page has actually
migrated out of primary memory.
</p>
</dd>
<dt> <code>R</code></dt>
<dd><p>Number of minor, or recoverable, page faults. These are pages that are
not valid (so they fault) but which have not yet been claimed by other
virtual pages. Thus the data in the page is still valid but the system
tables must be updated.
</p>
</dd>
<dt> <code>W</code></dt>
<dd><p>Number of times the process was swapped out of main memory.
</p>
</dd>
<dt> <code>c</code></dt>
<dd><p>Number of times the process was context-switched involuntarily (because
the time slice expired).
</p>
</dd>
<dt> <code>w</code></dt>
<dd><p>Number of times that the program was context-switched voluntarily, for
instance while waiting for an I/O operation to complete.
</p>
</dd>
<dt> <code>I</code></dt>
<dd><p>Number of file system inputs by the process.
</p>
</dd>
<dt> <code>O</code></dt>
<dd><p>Number of file system outputs by the process.
</p>
</dd>
<dt> <code>r</code></dt>
<dd><p>Number of socket messages received by the process.
</p>
</dd>
<dt> <code>s</code></dt>
<dd><p>Number of socket messages sent by the process.
</p>
</dd>
<dt> <code>k</code></dt>
<dd><p>Number of signals delivered to the process.
</p></dd>
</dl>
<hr size="6">
<a name="Command-Info"></a>
<a name="SEC7"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC6" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC8" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC1" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC3" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[ >> ]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[Index]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection"> 1.2.4 Command Info </h3>
<dl compact="compact">
<dt> <code>C</code></dt>
<dd><p>Name and command line arguments of the command being timed.
</p>
</dd>
<dt> <code>x</code></dt>
<dd><p>Exit status of the command.
</p></dd>
</dl>
<hr size="6">
<a name="Redirecting"></a>
<a name="SEC8"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC7" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC9" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC1" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC1" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[ >> ]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[Index]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 1.3 Redirecting Output </h2>
<p>By default, <code>time</code> writes the resource use statistics to the
standard error stream. The options below make it write the statistics
to a file instead. Doing this can be useful if the program you're
running writes to the standard error or you're running <code>time</code>
noninteractively or in the background.
</p>
<dl compact="compact">
<dt> <code>-o <var>file</var></code></dt>
<dt> <code>--output=<var>file</var></code></dt>
<dd><p>Write the resource use statistics to <var>file</var>. By default, this
<em>overwrites</em> the file, destroying the file's previous contents.
</p>
</dd>
<dt> <code>-a</code></dt>
<dt> <code>--append</code></dt>
<dd><p><em>Append</em> the resource use information to the output file instead
of overwriting it. This option is only useful with the ‘<samp>-o</samp>’ or
‘<samp>--output</samp>’ option.
</p></dd>
</dl>
<hr size="6">
<a name="Examples"></a>
<a name="SEC9"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC8" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC10" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC1" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC1" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[ >> ]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[Index]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 1.4 Examples </h2>
<p>Run the command ‘<samp>wc /etc/hosts</samp>’ and show the default information:
</p>
<table><tr><td> </td><td><pre class="example">eg$ time wc /etc/hosts
35 111 1134 /etc/hosts
0.00user 0.01system 0:00.04elapsed 25%CPU (0avgtext+0avgdata 0maxresident)k
1inputs+1outputs (0major+0minor)pagefaults 0swaps
</pre></td></tr></table>
<p>Run the command ‘<samp>ls -Fs</samp>’ and show just the user, system, and
wall-clock time:
</p>
<table><tr><td> </td><td><pre class="example">eg$ time -f "\t%E real,\t%U user,\t%S sys" ls -Fs
total 16
1 account/ 1 db/ 1 mail/ 1 run/
1 backups/ 1 emacs/ 1 msgs/ 1 rwho/
1 crash/ 1 games/ 1 preserve/ 1 spool/
1 cron/ 1 log/ 1 quotas/ 1 tmp/
0:00.03 real, 0.00 user, 0.01 sys
</pre></td></tr></table>
<p>Edit the file ‘<tt>.bashrc</tt>’ and have <code>time</code> append the elapsed time
and number of signals to the file ‘<tt>log</tt>’, reading the format string
from the environment variable <code>TIME</code>:
</p>
<table><tr><td> </td><td><pre class="example">eg$ export TIME="\t%E,\t%k" #<span class="roman"> If using bash or ksh</span>
eg$ setenv TIME "\t%E,\t%k" #<span class="roman"> If using csh or tcsh</span>
eg$ time -a -o log emacs .bashrc
eg$ cat log
0:16.55, 726
</pre></td></tr></table>
<p>Run the command ‘<samp>sleep 4</samp>’ and show all of the information about it
verbosely:
</p>
<table><tr><td> </td><td><pre class="example">eg$ time -v sleep 4
Command being timed: "sleep 4"
User time (seconds): 0.00
System time (seconds): 0.05
Percent of CPU this job got: 1%
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:04.26
Average shared text size (kbytes): 36
Average unshared data size (kbytes): 24
Average stack size (kbytes): 0
Average total size (kbytes): 60
Maximum resident set size (kbytes): 32
Average resident set size (kbytes): 24
Major (requiring I/O) page faults: 3
Minor (reclaiming a frame) page faults: 0
Voluntary context switches: 11
Involuntary context switches: 0
Swaps: 0
File system inputs: 3
File system outputs: 1
Socket messages sent: 0
Socket messages received: 0
Signals delivered: 1
Page size (bytes): 4096
Exit status: 0
</pre></td></tr></table>
<hr size="6">
<a name="Accuracy"></a>
<a name="SEC10"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC9" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC11" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC1" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC1" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[ >> ]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[Index]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 1.5 Accuracy </h2>
<p>The elapsed time is not collected atomically with the execution of the
program; as a result, in bizarre circumstances (if the <code>time</code>
command gets stopped or swapped out in between when the program being
timed exits and when <code>time</code> calculates how long it took to run), it
could be much larger than the actual execution time.
</p>
<p>When the running time of a command is very nearly zero, some values
(e.g., the percentage of CPU used) may be reported as either zero (which
is wrong) or a question mark.
</p>
<p>Most information shown by <code>time</code> is derived from the <code>wait3</code>
system call. The numbers are only as good as those returned by
<code>wait3</code>. Many systems do not measure all of the resources that
<code>time</code> can report on; those resources are reported as zero. The
systems that measure most or all of the resources are based on 4.2 or
4.3BSD. Later BSD releases use different memory management code that
measures fewer resources.
</p>
<p>On systems that do not have a <code>wait3</code> call that returns status
information, the <code>times</code> system call is used instead. It provides
much less information than <code>wait3</code>, so on those systems <code>time</code>
reports most of the resources as zero.
</p>
<p>The ‘<samp>%I</samp>’ and ‘<samp>%O</samp>’ values are allegedly only “real” input
and output and do not include those supplied by caching devices. The
meaning of “real” I/O reported by ‘<samp>%I</samp>’ and ‘<samp>%O</samp>’ may be
muddled for workstations, especially diskless ones.
</p>
<hr size="6">
<a name="Invoking-time"></a>
<a name="SEC11"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC10" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[ > ]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC1" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC1" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[ >> ]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[Index]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 1.6 Running the <code>time</code> Command </h2>
<p>The format of the <code>time</code> command is:
</p>
<table><tr><td> </td><td><pre class="example">time <span class="roman">[</span>option…<span class="roman">]</span> <var>command</var> <span class="roman">[</span><var>arg</var>…<span class="roman">]</span>
</pre></td></tr></table>
<a name="IDX3"></a>
<p><code>time</code> runs the program <var>command</var>, with any given arguments
<var>arg</var>…. When <var>command</var> finishes, <code>time</code> displays
information about resources used by <var>command</var> (on the standard error
output, by default). If <var>command</var> exits with non-zero status or is
terminated by a signal, <code>time</code> displays a warning message and the
exit status or signal number.
</p>
<p>Options to <code>time</code> must appear on the command line before
<var>command</var>. Anything on the command line after <var>command</var> is
passed as arguments to <var>command</var>.
</p>
<dl compact="compact">
<dt> <code>-o <var>file</var></code></dt>
<dt> <code>--output=<var>file</var></code></dt>
<dd><p>Write the resource use statistics to <var>file</var>.
</p>
</dd>
<dt> <code>-a</code></dt>
<dt> <code>--append</code></dt>
<dd><p><em>Append</em> the resource use information to the output file instead
of overwriting it.
</p>
</dd>
<dt> <code>-f <var>format</var></code></dt>
<dt> <code>--format=<var>format</var></code></dt>
<dd><p>Use <var>format</var> as the format string.
</p>
</dd>
<dt> <code>--help</code></dt>
<dd><p>Print a summary of the command line options to <code>time</code> and exit.
</p>
</dd>
<dt> <code>-p</code></dt>
<dt> <code>--portability</code></dt>
<dd><p>Use the POSIX format.
</p>
</dd>
<dt> <code>-v</code></dt>
<dt> <code>--verbose</code></dt>
<dd><a name="IDX4"></a>
<p>Use the built-in verbose format.
</p>
</dd>
<dt> <code>-V</code></dt>
<dt> <code>--version</code></dt>
<dd><a name="IDX5"></a>
<p>Print the version number of <code>time</code> and exit.
</p></dd>
</dl>
<hr size="6">
<a name="SEC_Contents"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[Index]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h1>Table of Contents</h1>
<div class="contents">
<ul class="toc">
<li><a name="TOC1" href="#SEC1">1. Measuring Program Resource Use</a>
<ul class="toc">
<li><a name="TOC2" href="#SEC2">1.1 Setting the Output Format</a></li>
<li><a name="TOC3" href="#SEC3">1.2 The Format String</a>
<ul class="toc">
<li><a name="TOC4" href="#SEC4">1.2.1 Time Resources</a></li>
<li><a name="TOC5" href="#SEC5">1.2.2 Memory Resources</a></li>
<li><a name="TOC6" href="#SEC6">1.2.3 I/O Resources</a></li>
<li><a name="TOC7" href="#SEC7">1.2.4 Command Info</a></li>
</ul></li>
<li><a name="TOC8" href="#SEC8">1.3 Redirecting Output</a></li>
<li><a name="TOC9" href="#SEC9">1.4 Examples</a></li>
<li><a name="TOC10" href="#SEC10">1.5 Accuracy</a></li>
<li><a name="TOC11" href="#SEC11">1.6 Running the <code>time</code> Command</a></li>
</ul>
</li>
</ul>
</div>
<hr size="1">
<a name="SEC_About"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[Index]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h1>About This Document</h1>
<p>
This document was generated by <em>root</em> on <em>July, 21 2008</em> using <a href="http://www.nongnu.org/texi2html/"><em>texi2html 1.78</em></a>.
</p>
<p>
The buttons in the navigation panels have the following meaning:
</p>
<table border="1">
<tr>
<th> Button </th>
<th> Name </th>
<th> Go to </th>
<th> From 1.2.3 go to</th>
</tr>
<tr>
<td align="center"> [ < ] </td>
<td align="center">Back</td>
<td>Previous section in reading order</td>
<td>1.2.2</td>
</tr>
<tr>
<td align="center"> [ > ] </td>
<td align="center">Forward</td>
<td>Next section in reading order</td>
<td>1.2.4</td>
</tr>
<tr>
<td align="center"> [ << ] </td>
<td align="center">FastBack</td>
<td>Beginning of this chapter or previous chapter</td>
<td>1</td>
</tr>
<tr>
<td align="center"> [ Up ] </td>
<td align="center">Up</td>
<td>Up section</td>
<td>1.2</td>
</tr>
<tr>
<td align="center"> [ >> ] </td>
<td align="center">FastForward</td>
<td>Next chapter</td>
<td>2</td>
</tr>
<tr>
<td align="center"> [Top] </td>
<td align="center">Top</td>
<td>Cover (top) of document</td>
<td> </td>
</tr>
<tr>
<td align="center"> [Contents] </td>
<td align="center">Contents</td>
<td>Table of contents</td>
<td> </td>
</tr>
<tr>
<td align="center"> [Index] </td>
<td align="center">Index</td>
<td>Index</td>
<td> </td>
</tr>
<tr>
<td align="center"> [ ? ] </td>
<td align="center">About</td>
<td>About (help)</td>
<td> </td>
</tr>
</table>
<p>
where the <strong> Example </strong> assumes that the current position is at <strong> Subsubsection One-Two-Three </strong> of a document of the following structure:
</p>
<ul>
<li> 1. Section One
<ul>
<li>1.1 Subsection One-One
<ul>
<li>...</li>
</ul>
</li>
<li>1.2 Subsection One-Two
<ul>
<li>1.2.1 Subsubsection One-Two-One</li>
<li>1.2.2 Subsubsection One-Two-Two</li>
<li>1.2.3 Subsubsection One-Two-Three
<strong><== Current Position </strong></li>
<li>1.2.4 Subsubsection One-Two-Four</li>
</ul>
</li>
<li>1.3 Subsection One-Three
<ul>
<li>...</li>
</ul>
</li>
<li>1.4 Subsection One-Four</li>
</ul>
</li>
</ul>
<hr size="1">
<p>
<font size="-1">
This document was generated by <em>root</em> on <em>July, 21 2008</em> using <a href="http://www.nongnu.org/texi2html/"><em>texi2html 1.78</em></a>.
</font>
<br>
</p>
</body>
</html>
|