>>> Dejan Muhamedagic <[email protected]> schrieb am 30.11.2011 um 15:35 in
Nachricht <[email protected]>:
> Hi,
> 
> On Wed, Nov 30, 2011 at 02:56:34PM +0100, Ulrich Windl wrote:
> > Hi!
> > 
> > It seems the execution time is shown in milliseconds. However it seems all 
> execution times are multiples of 10ms. Is that intended?
> > 
> > Examples (human readable times):
> > exec-time="0"
> > exec-time="100ms"
> > exec-time="10ms"
> > exec-time="70ms"
> > exec-time="70ms"
> > exec-time="70ms"
> > exec-time="710ms"
> > exec-time="710ms"
> > exec-time="7s500ms"
> > exec-time="80ms"
> > exec-time="820ms"
> > exec-time="850ms"
> > exec-time="870ms"
> > exec-time="880ms"
> > exec-time="90ms"
> > exec-time="910ms"
> > exec-time="910ms"
> 
> That's the clock resolution (10ms) for this purpose. I think it's
> platform dependent, but I cannot recall seeing anything with
> finer resolution (see _SC_CLK_TCK)

Hi!

I don't know how you measure your runtime, but even gettimeofday() has a better 
resolution. Is that exec-time the wall-time, or is it CPU-time?

I don't think it makes much sense to use CPU-time there.

Even then, I cannot reproduce the result:
"CPU time used = 0.004" says the following program:

#include <stdio.h>
#include <string.h>
#include <sys/time.h>
#include <sys/resource.h>

static  int     get_cpu_usage(struct timeval *tvp)
{
        struct rusage   res;

        if ( getrusage(RUSAGE_SELF, &res) != 0 )
                return(-1);
        tvp->tv_sec = res.ru_utime.tv_sec;
        tvp->tv_usec = res.ru_utime.tv_usec;
        return(0);
}

int     main(int argc, char *argv[])
{
        struct timeval  tv, now;

        if (get_cpu_usage(&tv) == 0) {
                while (get_cpu_usage(&now) == 0 &&
                       memcmp(&tv, &now, sizeof(tv)) == 0) {
                }
                now.tv_usec -= tv.tv_usec;
                now.tv_sec -= tv.tv_sec;
                if (now.tv_usec < 0)
                        now.tv_usec += 1000000, now.tv_sec -= 1;
                printf("CPU time used = %g\n",
                       now.tv_sec + (double) now.tv_usec / 1000000);
        }
        return 0;
}

So what are you doing here?

Regards,
Ulrich




_______________________________________________
Linux-HA mailing list
[email protected]
http://lists.linux-ha.org/mailman/listinfo/linux-ha
See also: http://linux-ha.org/ReportingProblems

Reply via email to