Change gettimeofday to clock_gettime => nanosecond resolution.