Re: [PATCH] MI: new timing command

Eli Zaretskii
2007-01-28T04:17:37Z

> From: Nick Roberts <nickrob@snap.net.nz>
> Date: Sun, 28 Jan 2007 11:08:45 +1300
> Cc: gdb-patches@sources.redhat.com
>
> Well it was explained to me that get_run_time basically returns wallclock
> time when getrusage isn't defined.

Not necessarily. Take a look at getruntime.c: it can use `times' when
that is available. `times' returns the sum of user and system times,
not the wallclock time.

> > I suggest to use gettimeofday to compute wallclock time on all
> > platforms, and avoid using struct rusage in struct mi_timestamp,
> > e.g. like this:
> >
> > struct mi_timestamp {
> > struct timeval wallclock;
> > struct timeval utime;
> > struct timeval stime'
> > }
> >
> > Then in mi-main.c:timestamp you could copy the values from what
> > getrusage returns to the utime and stime members of mi_timestamp, when
> > getrusage is available, and if not, assign the value returned by
> > get_run_time to members of utime.
>
> Won't the members wallclock and utime be basically the same now?

Not if `times' is used in get_run_time.

> Would something like below work? When getrusage isn't defined I just use
> wallclock. There's no need to define utime or stime in this case as the
> values are always 0.

That would work, but I think we shouldn't lose the important case of
platforms which have `times'.