time command output

Jonathan I. Kamens jik at athena.mit.edu
Fri Feb 2 03:56:29 AEST 1990


In article <DRICH.90Jan29082947 at klaatu.lanl.gov>, drich at klaatu.lanl.gov
(David Rich) writes:
> What do the numbers mean in the output of the (csh) time
> command? The documentation simply says that you get user,
> system and elapsed time (along with a "utilization" percentage).
> How do these numbers relate to each other (typically, user and
> system don't add up to elapsed)? What are the other numbers?
> pf=page faults? io?

A message I've saved up from a while back:

Subject: csh "time" fields
From: dvk at sei.cmu.edu (Daniel Klein)
Newsgroups: net.unix
Subject: csh "time" fields
Date: 17 Oct 86 16:35:27 GMT
Date-Received: 18 Oct 86 05:04:12 GMT
Sender: netnews at sei.cmu.edu
Organization: Carnegie-Mellon University, SEI, Pgh, Pa
Lines: 58
Keywords: csh, time, undocumented features

Experienced people, read this too.  It may prove interesting!  A description
of an undocumented 'csh' feature follows, along with a description of the
fields in the 'csh' time command.

The first field is user CPU time, in seconds.
The second field is system CPU time, in seconds.
The third field is elapsed time, in minute:seconds.
The fourth field is the ratio of CPU time/elapsed time.
The fifth field is the measure of memory usage (text size+data size), in
    KBytes of memory (this is ru_ixrss and ru_idrss from <sys/resource.h>)
The sixth field is a measure of I/O activity (input+output), in "blocks"
    (this is ru_inblock and ru_oublock, respectively)
The seventh field is the number of hard page faults you generated and the
    number of swap outs of your process (ru_majflt and ru_nswap respectively)


Now for the undocumented feature!  It turns out that the "time" command
prints out the times via a printf-like string, which by default is the string
"%Uu %Ss %E %P %X+%Dk %I+%Oio %Fpf+%Ww" (I'll explain the fields in a second).
According to the 'csh' man page, you can set the shell variable "time" to be
a number, and if any command takes longer than that many seconds, it will
print the times fields as above.  What is undocumented is that you can have a
second field to the "time" variable, which is the format string to use.  So
if you just wanted to print the user and system times, and the text and data
sizes of your image (and nothing else), you could tell the shell:

        set time = (5 "%Uu %Ss %X+%Dk")

This would print the required fields if the command ran longer than 5 seconds.

Now, what do all the fields (there are more) stand for?

        %U      user cpu time
        %S      system cpu time
        %E      elapsed (wall clock) time
        %P      percentage utilization (cpu_time/elapsed_time)
        %X      text_size/cpu_second (ru_ixrss/cpu_time)
        %D      data_size/cpu_second ((ru_idrss+ru_isrss)/cpu_time)
        %K      image_size/cpu_second ((ru_ixrss+ru_idrss+ru_isrss)/cpu_time)
        %M      maximum image size (ru_maxrss/2  -- I don't know why /2)
        %I      number of input blocks (ru_inblock)
        %O      number of output blocks (ru_oublock)
        %F      number of hard page faults (ru_majflt)
        %R      number of page reclaims (ru_minflt)
        %W      number of swap-outs (ru_nswap)

The values for %X, %D, and %K are pretty useless, since they often have
values of 0 (all of the resource size variables are generally monotonically
increasing, and I think the attempt was made to give a value akin to
kilo-core seconds, but it doesn't work well for anything by I/O bound jobs,
since it uses integer division!).  Hope all this helps.
--
==-------------==-------------==-------------==-------------==-------------==
Daniel V. Klein, who recently gave up a lucrative job as a freelance consultant
to go work for the warmongering SEI, and is, frankly, enjoying himself.

                ARPA:   dvk at sei.cmu.edu
                USENET: ucbvax!dvk at sei          (questionable link)

Jonathan Kamens			              USnail:
MIT Project Athena				11 Ashford Terrace
jik at Athena.MIT.EDU				Allston, MA  02134
Office: 617-253-8495			      Home: 617-782-0710



More information about the Comp.unix.questions mailing list