The tv_usec field in struct timeval is supposed to store the number of microseconds since January 1, 1970 00:00. But when I do the following:
The values I get for start.tv_usec and end.tv_usec are not increasing after every run of the program. For example, I'll getCode:#include <sys/time.h> int main() { int i; struct timeval start, end; struct timezone tzp; gettimeofday(&start, &tzp); for(i = 0; i < 100000; i++){} gettimeofday(&end, &tzp); printf("start: %lu\n", start.tv_usec); printf("end: %lu\n", end.tv_usec); printf("time: %lu\n", end.tv_usec - start.tv_usec); return 0; }
start: 609659
end: 610257
and in another run afterwards I'll get
start: 204615
end: 205695