[Intel-gfx] [PATCH i-g-t v3] lib/igt_core: Prefer CLOCK_MONOTONIC_RAW
Chris Wilson
chris at chris-wilson.co.uk
Wed Nov 18 05:07:39 PST 2015
On Wed, Nov 18, 2015 at 02:54:20PM +0200, Joonas Lahtinen wrote:
> On ke, 2015-11-18 at 12:28 +0000, Chris Wilson wrote:
> > On Wed, Nov 18, 2015 at 02:18:52PM +0200, Joonas Lahtinen wrote:
> > > CLOCK_MONOTONIC_RAW is not affected by NTP, so it should be THE
> > > clock
> > > used for timing execution of tests.
> > >
> > > When fetching either the starting or ending time of a test, show
> > > the
> > > time as -1.000s.
> > >
> > > v3:
> > > - Do not exit directly from handler (Chris)
> > > - Show elapsed time as -1 if it is not calculable
> >
> > Aye, that's better for the subtest handling.
> >
> > > @@ -832,10 +851,16 @@ static void exit_subtest(const char *result)
> > > {
> > > struct timespec now;
> > > double elapsed;
> > > + int err;
> > >
> > > - gettime(&now);
> > > - elapsed = now.tv_sec - subtest_time.tv_sec;
> > > - elapsed += (now.tv_nsec - subtest_time.tv_nsec) * 1e-9;
> > > + err = gettime(&now);
> > > + if (!err && subtest_time.tv_sec != 0 &&
> > > + subtest_time.tv_nsec != 0) {
> >
> > A little paranoid? If we want the paranoia perhaps move it to gettime
> > and return an error?
> >
>
> I'm just checking that the starting time which is in the subtest_time
> did not fail (which leads to both being zero). I'm not looking at the
> now values :)
Ok, now I see.
#define time_valid(ts) ((ts)->tv_sec || (ts)->tv_nsec)
gettime(&now);
if (time_valid(&now) && time_valid(&subtest_time)) {
elapsed = ...;
} else {
elapsed = -1;
}
Perhaps?
-Chris
--
Chris Wilson, Intel Open Source Technology Centre
More information about the Intel-gfx
mailing list