question on timing results

Globe Trotter itsme_410 at yahoo.com
Thu Jun 16 13:49:00 UTC 2005


--- Matthew Saltzman <mjs at ces.clemson.edu> wrote:

> On Thu, 9 Jun 2005, Globe Trotter wrote:
> 
> >
> >>> clock() returns an approximation of the CPU time used by the actual
> >> process,
> >>> so while load from other programs is a factor (particularly since it'll
> >> make
> >>> your program wait for IO, etc.) it should do basically what you want.
> >>
> >> Also check out the times(2) facility.  It's not ISO C, but it is POSIX and
> >> it has some advantages over clock(3).
> >>
> >> --
> >>
> >
> > Thanks, what exactly are the advantages? These are sometimes long 
> > calculations so the processor will be running for long. Also, is there
> 
> clock() will wrap after about 75 CPU minutes.  I believe times() will not.
> 
> Also times() tracks user and system time separately, and it tracks parent 
> and child process times separately.
> 
> > an example on using times(2) somewhere? A Google search on times(2) 
> > example C did not reveal much, but the choice of keywords may not have 
> > been apt. (One problem with the name of the language called C is that is 
> > just a letter, as opposed to fortran/C++/pascal et al, which is more 
> > distinctive.
> 
> Don't know of a handy URL, sorry.  The man page ("man 2 times") and a 
> little experimentation should be enough.
> 

Hi,

Here is an example cooked up just to show how it works. Only done with utime
and stime, but can be extended to the other two in exactly the same way. But I
wonder, which should be used? As per the manpage for times(2), the function
reports the value of four times in four fields. 1)  The tms_utime field
contains the CPU time spent executing  instructions of  the  calling  process. 
2) The  tms_stime field contains the CPU time spent in the system while
executing tasks on behalf of the calling process.  3) The  tms_cutime  field 
contains  the  sum of the tms_utime and  tms_cutime  values  for  all 
waited-for  terminated   children. 4) The tms_cstime  field contains the sum of
the tms_stime and tms_cstime values for all waited-for terminated children.

My programs go into an algorithm and do lots of things. Which times shoudl I
use?  I don't understand all this much: I am considering using the tms_utime
field, but I don't know if I should use that or the sum of the first two or all
of them. Any suggestions: I guess I really don't know what all these 
different times mean.

Many thanks and best wishes!


		
__________________________________ 
Discover Yahoo! 
Use Yahoo! to plan a weekend, have fun online and more. Check it out! 
http://discover.yahoo.com/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: times.c
Type: text/x-csrc
Size: 986 bytes
Desc: 2576313263-times.c
URL: <http://listman.redhat.com/archives/fedora-list/attachments/20050616/6330b2f1/attachment-0001.bin>


More information about the fedora-list mailing list