/* * realtime_(): * * Returns the number of real time seconds from the last * call to realtime_(); returns 0 on first call. * May be called from FORTRAN as (double precision) realtime(). * * Tested for SUN, ES1, SPS-2, RS-6000 */ #ifdef SPS #ifdef PAR #include #else PAR #include #endif PAR #else SPS #include #endif SPS #define tim(tv) (double) (tv.tv_sec + 1.e-6 * tv.tv_usec) double realtime(); double realtime_() { return realtime(); } #ifndef SPS double realtime() { static struct timeval tv; static struct timezone tz; gettimeofday(&tv,&tz); return tim(tv); } #endif SPS #ifdef TEST #include main() { double realtime_(), t1, t2; char c; printf("Hit return to end timing... \n"); t1 = realtime_(); c =getchar(); t2 = realtime_(); printf("Elapsed time: %8.2f secs.\n", t2-t1); } #endif