msach@0: /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ msach@0: /* File: wtime.c */ msach@0: /* Description: a timer that reports the current wall time */ msach@0: /* */ msach@0: /* Author: Wei-keng Liao */ msach@0: /* ECE Department Northwestern University */ msach@0: /* email: wkliao@ece.northwestern.edu */ msach@0: /* Copyright, 2005, Wei-keng Liao */ msach@0: /* */ msach@0: /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ msach@0: msach@0: #include msach@0: #include msach@0: #include msach@0: msach@0: /* msach@0: * Function: wtime msach@0: * --------------- msach@0: * Provides a millisecond-resolution timer for measurement purposes. msach@0: */ msach@0: double wtime(void) msach@0: { msach@0: double now_time; msach@0: struct timeval etstart; msach@0: struct timezone tzp; msach@0: msach@0: if (gettimeofday(&etstart, &tzp) == -1) { msach@0: fprintf(stderr, "Timing Error: Could Not Get Current Time\n"); msach@0: exit(EXIT_FAILURE); msach@0: } msach@0: msach@0: now_time = ((double)etstart.tv_sec) + /* in seconds */ msach@0: ((double)etstart.tv_usec) / 1000000.0; /* in microseconds */ msach@0: return now_time; msach@0: } msach@0: msach@0: