I wish to note CPU time taken by a program. What I have done and assume is
as below. Correct me and suggest some solution.

I tried using "time ./a.out" it gave three time and think "user" is
relevent. But I observed this "user time " vary with other load on PC.

Then I tried using  following arrangement:

clock_t ct1, ct2;
tms cputime1, cputime2;
ct1 = times(&cputime1) ;
        {
                // computer code
        }
ct2 =   times(&cputime2) ;
cout << "\n usertime " <<( cputime2.tms_utime -  cputime1.tms_utime
        + cputime2.tms_cutime-  cputime1.tms_cutime)/(CLOCKS_PER_SEC/10000.)

This user time, I also find senstive to number of programs running on PC.

My doubts are as:

1) In above "cout" statement should I add difference of "tms_cutime" or
not.

2) Is there any other way ( if this is not the right method ) to note CPU
time taken by some segment of a program, which is independent of load of
PC.

3) Is it so that some variation is normal ( something like least count or
sampling error ), and can not be large enough to cause any seroius
concern. With less load I get time 1.07 sec and when movie is also going
on it gave me 1.21.

Thanks in advance.

H.S.Rai



_______________________________________________
linux-india-help mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/linux-india-help

Reply via email to