made time use times() system call to get higher resolution (1/60s clock

ticks instead of 1s) for real time measurement.
This commit is contained in:
Ben Gras 2005-05-20 10:06:33 +00:00
parent d0a5a5d007
commit cff515edd8

View File

@ -39,7 +39,8 @@ char *argv[];
#if _VMD_EXT #if _VMD_EXT
struct timeval start_time, end_time; struct timeval start_time, end_time;
#else #else
time_t start_time, end_time; struct tms dummy;
int start_time, end_time;
#endif #endif
clock_t real_time; clock_t real_time;
@ -52,7 +53,7 @@ char *argv[];
#if _VMD_EXT #if _VMD_EXT
(void) sysutime(UTIME_TIMEOFDAY, &start_time); (void) sysutime(UTIME_TIMEOFDAY, &start_time);
#else #else
(void) time(&start_time); start_time = times(&dummy);
#endif #endif
/* Fork off child. */ /* Fork off child. */
@ -74,8 +75,8 @@ char *argv[];
real_time = (end_time.tv_sec - start_time.tv_sec) * CLOCKS_PER_SEC real_time = (end_time.tv_sec - start_time.tv_sec) * CLOCKS_PER_SEC
+ (end_time.tv_usec - start_time.tv_usec) * CLOCKS_PER_SEC / 1000000; + (end_time.tv_usec - start_time.tv_usec) * CLOCKS_PER_SEC / 1000000;
#else #else
(void) time(&end_time); end_time = times(&dummy);
real_time = (end_time - start_time) * CLOCKS_PER_SEC; real_time = (end_time - start_time);
#endif #endif
if ((status & 0377) != 0) std_err("Command terminated abnormally.\n"); if ((status & 0377) != 0) std_err("Command terminated abnormally.\n");