On Wed, Jun 27, 2012 at 4:42 PM, Adam Jackson <a...@redhat.com> wrote: > On Wed, 2012-06-27 at 09:29 +0200, Michel Dänzer wrote: >> On Mit, 2012-06-27 at 03:49 +0200, Marek Olšák wrote: >> > >> > +GLuint64 >> > +_mesa_get_cpu_timestamp(void) >> > +{ >> > +#ifndef _WIN32 >> > + struct timeval tv; >> > + >> > + gettimeofday(&tv, 0); >> > + return (GLuint64)tv.tv_sec * 1000000000ull + (GLuint64)tv.tv_usec * >> > 1000; >> >> As in a recent discussion about DRM vblank counters, it may be better to >> use clock_gettime(CLOCK_MONOTONIC, ...) when possible, as gettimeofday() >> can move backwards. > > And if you do so, since it looks like you're working in milliseconds, > please steal xserver's GetTimeInMillis() for it: > > http://cgit.freedesktop.org/xorg/xserver/tree/os/utils.c#n409 > http://cgit.freedesktop.org/xorg/xserver/commit/os/utils.c?id=44adb31bfece29260a9bbd9075c9212ebf00d24d
I am working in nanoseconds and precision is quite important. I don't think I can use CLOCK_MONOTONIC_COARSE. CLOCK_MONOTONIC might be fine. Marek _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev