[net.unix] csh "time" fields

dvk@sei.cmu.edu (Daniel Klein) (10/17/86)

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@sei.cmu.edu
		USENET:	ucbvax!dvk@sei		(questionable link)