#ifdef GETTIMEOFDAY #include // For struct timeval, gettimeofday #else #include // For struct timespec, clock_gettime, CLOCK_MONOTONIC #endif #include #include double wall_time() { #ifdef GETTIMEOFDAY struct timeval t; gettimeofday(&t, NULL); return 1. * t.tv_sec + 1.e-6 * t.tv_usec; #else struct timespec t; clock_gettime(CLOCK_MONOTONIC, &t); return 1. * t.tv_sec + 1.e-9 * t.tv_nsec; #endif } void die(const char *message) { perror(message); exit(EXIT_FAILURE); }