reintroduce ftime as fallback
This commit is contained in:
parent
90c5825855
commit
2d699dafad
|
|
@ -908,7 +908,7 @@ AC_STRUCT_TM
|
|||
AC_STRUCT_TIMEZONE
|
||||
AC_CHECK_FUNCS([localtime])
|
||||
|
||||
AC_CHECK_FUNCS([clock_gettime gettimeofday times ftime])
|
||||
AC_CHECK_FUNCS([clock_gettime gettimeofday ftime times])
|
||||
|
||||
# Do not use time or getrusage function for CPU time measurement under OpenMP
|
||||
if test "x$enable_openmp" = xno; then
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ init_rlimits(void)
|
|||
ft_ckspace();
|
||||
}
|
||||
|
||||
#if defined HAVE_CLOCK_GETTIME || defined HAVE_GETTIMEOFDAY
|
||||
#if defined HAVE_CLOCK_GETTIME || defined HAVE_GETTIMEOFDAY || defined HAVE_FTIME
|
||||
PortableTime timebegin;
|
||||
#endif
|
||||
|
||||
|
|
@ -88,7 +88,7 @@ init_time(void)
|
|||
#else
|
||||
# ifdef HAVE_TIMES
|
||||
# else
|
||||
# if defined HAVE_CLOCK_GETTIME || defined HAVE_GETTIMEOFDAY
|
||||
# if defined HAVE_CLOCK_GETTIME || defined HAVE_GETTIMEOFDAY || defined HAVE_FTIME
|
||||
get_portable_time(&timebegin);
|
||||
# endif
|
||||
# endif
|
||||
|
|
@ -172,7 +172,13 @@ printres(char *name)
|
|||
if (!name || eq(name, "totalcputime") || eq(name, "cputime")) {
|
||||
int total_sec, total_msec;
|
||||
|
||||
# ifdef HAVE_GETRUSAGE
|
||||
#if defined HAVE_CLOCK_GETTIME || defined HAVE_GETTIMEOFDAY || defined HAVE_FTIME
|
||||
PortableTime timenow;
|
||||
get_portable_time(&timenow);
|
||||
timediff(&timenow, &timebegin, &total_sec, &total_msec);
|
||||
cpu_elapsed = "elapsed";
|
||||
#else
|
||||
#ifdef HAVE_GETRUSAGE
|
||||
int ret;
|
||||
struct rusage ruse;
|
||||
memset(&ruse, 0, sizeof(ruse));
|
||||
|
|
@ -183,8 +189,8 @@ printres(char *name)
|
|||
total_sec = (int) (ruse.ru_utime.tv_sec + ruse.ru_stime.tv_sec);
|
||||
total_msec = (int) (ruse.ru_utime.tv_usec + ruse.ru_stime.tv_usec) / 1000;
|
||||
cpu_elapsed = "CPU";
|
||||
# else
|
||||
# ifdef HAVE_TIMES
|
||||
#else
|
||||
#ifdef HAVE_TIMES
|
||||
struct tms ruse;
|
||||
times(&ruse);
|
||||
clock_t x = ruse.tms_utime + ruse.tms_stime;
|
||||
|
|
@ -192,13 +198,7 @@ printres(char *name)
|
|||
total_sec = x / hz;
|
||||
total_msec = ((x % hz) * 1000) / hz;
|
||||
cpu_elapsed = "CPU";
|
||||
# else
|
||||
#if defined HAVE_CLOCK_GETTIME || defined HAVE_GETTIMEOFDAY
|
||||
PortableTime timenow;
|
||||
get_portable_time(&timenow);
|
||||
timediff(&timenow, &timebegin, &total_sec, &total_msec);
|
||||
cpu_elapsed = "elapsed";
|
||||
# else
|
||||
#else
|
||||
# define NO_RUDATA
|
||||
# endif
|
||||
# endif
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ datestring(void)
|
|||
|
||||
/* return time interval in seconds and milliseconds */
|
||||
|
||||
#if defined HAVE_CLOCK_GETTIME || defined HAVE_GETTIMEOFDAY
|
||||
#if defined HAVE_CLOCK_GETTIME || defined HAVE_GETTIMEOFDAY || defined HAVE_FTIME
|
||||
|
||||
void timediff(PortableTime *now, PortableTime *begin, int *sec, int *msec)
|
||||
{
|
||||
|
|
@ -70,12 +70,23 @@ void get_portable_time(PortableTime *pt) {
|
|||
pt->milliseconds = ts.tv_nsec / 1000000; // Convert nanoseconds to milliseconds
|
||||
}
|
||||
#else
|
||||
#ifdef HAVE_GETTIMEOFDAY
|
||||
void get_portable_time(PortableTime *pt) {
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, NULL);
|
||||
pt->seconds = tv.tv_sec;
|
||||
pt->milliseconds = tv.tv_usec / 1000;
|
||||
pt->milliseconds = tv.tv_usec / 1000; // Convert microseconds to milliseconds
|
||||
}
|
||||
#else
|
||||
#ifdef HAVE_FTIME
|
||||
void get_portable_time(PortableTime *pt) {
|
||||
struct timeb timenow;
|
||||
ftime(&timenow);
|
||||
pt->seconds = timenow.time;
|
||||
pt->milliseconds = timenow.millitm;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -88,6 +99,15 @@ void get_portable_time(PortableTime *pt) {
|
|||
double
|
||||
seconds(void)
|
||||
{
|
||||
#if defined HAVE_CLOCK_GETTIME || defined HAVE_GETTIMEOFDAY || defined HAVE_FTIME
|
||||
PortableTime timenow;
|
||||
PortableTime timebegin;
|
||||
int sec, msec;
|
||||
|
||||
get_portable_time(&timenow);
|
||||
timediff(&timenow, &timebegin, &sec, &msec);
|
||||
return(sec + (double) msec / 1000.0);
|
||||
#else
|
||||
#ifdef HAVE_GETRUSAGE
|
||||
int ret;
|
||||
struct rusage ruse;
|
||||
|
|
@ -107,21 +127,11 @@ seconds(void)
|
|||
times(&tmsbuf);
|
||||
return((double) tmsbuf.tms_utime / HZ);
|
||||
|
||||
#else
|
||||
#if defined HAVE_CLOCK_GETTIME || defined HAVE_GETTIMEOFDAY
|
||||
PortableTime timenow;
|
||||
PortableTime timebegin;
|
||||
int sec, msec;
|
||||
|
||||
get_portable_time(&timenow);
|
||||
timediff(&timenow, &timebegin, &sec, &msec);
|
||||
return(sec + (double) msec / 1000.0);
|
||||
|
||||
#else /* unknown */
|
||||
|
||||
return(-1.0); /* Obvious error condition */
|
||||
|
||||
#endif /* GETTIMEOFDAY || CLOCK_GETTIME */
|
||||
#endif /* TIMES */
|
||||
#endif /* GETRUSAGE */
|
||||
#endif /* TIMES */
|
||||
#endif /* CLOCK_GETTIME || GETTIMEOFDAY || FTIME */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
char * datestring(void);
|
||||
double seconds(void);
|
||||
|
||||
#if defined HAVE_CLOCK_GETTIME || defined HAVE_GETTIMEOFDAY
|
||||
#if defined HAVE_CLOCK_GETTIME || defined HAVE_GETTIMEOFDAY || defined HAVE_FTIME
|
||||
|
||||
typedef struct {
|
||||
long seconds;
|
||||
|
|
|
|||
Loading…
Reference in New Issue