17 #ifndef ZORBA_UTIL_TIME_H
18 #define ZORBA_UTIL_TIME_H
62 #if (defined(ZORBA_HAVE_CLOCKGETTIME_FUNCTION) & defined(_POSIX_CPUTIME))
66 typedef struct timespec cputime;
70 return ((t1.tv_sec - t0.tv_sec) * 1000.0) +
71 ((t1.tv_nsec - t0.tv_nsec) / 1000000.0);
76 clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &t);
79 #elif defined(ZORBA_HAVE_RUSAGE_FUNCTION)
82 #include <sys/resource.h>
84 typedef struct timeval cputime;
88 return ((t1.tv_sec - t0.tv_sec) * 1000.0) +
89 ((t1.tv_usec - t0.tv_usec) / 1000.0);
95 getrusage (RUSAGE_SELF, &ru);
107 return (
double) (t1 - t0) / (CLOCKS_PER_SEC / 1000);
124 #if defined(ZORBA_HAVE_CLOCKGETTIME_FUNCTION)
132 return ((t1.tv_sec - t0.tv_sec) * 1000.0) +
133 ((t1.tv_nsec - t0.tv_nsec) / 1000000.0);
138 #ifdef _POSIX_MONOTONIC_CLOCK
139 clock_gettime(CLOCK_MONOTONIC, &t);
141 clock_gettime(CLOCK_REALTIME, &t);
147 return t.tv_sec * 1000 + t.tv_nsec / 1000000;
157 #include <sys/timeb.h>
167 return ((t1.time - t0.time) * 1000.0) + (t1.millitm - t0.millitm);
181 return (
long)(t.time * 1000 + t.millitm);
187 #include <sys/time.h>
193 return ((t1.tv_sec - t0.tv_sec) * 1000.0) +
194 ((t1.tv_usec - t0.tv_usec) / 1000.0);
199 gettimeofday(&t, NULL);
204 return t.tv_sec * 1000 + t.tv_usec / 1000;