17 #ifndef ZORBA_UTIL_TIME_H
18 #define ZORBA_UTIL_TIME_H
20 #include <zorba/config.h>
59 #if ZORBA_SIZEOF_LONG <= 4
71 #if (defined(ZORBA_HAVE_CLOCKGETTIME_FUNCTION) & defined(_POSIX_CPUTIME))
75 typedef struct timespec
cputime;
79 return ((t1.tv_sec - t0.tv_sec) * 1000.0) +
80 ((t1.tv_nsec - t0.tv_nsec) / 1000000.0);
85 clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &t);
88 #elif defined(ZORBA_HAVE_RUSAGE_FUNCTION)
91 #include <sys/resource.h>
97 return ((t1.tv_sec - t0.tv_sec) * 1000.0) +
98 ((t1.tv_usec - t0.tv_usec) / 1000.0);
104 getrusage (RUSAGE_SELF, &
ru);
116 return (
double) (t1 - t0) / (CLOCKS_PER_SEC / 1000);
133 #if defined(ZORBA_HAVE_CLOCKGETTIME_FUNCTION)
141 return ((t1.tv_sec - t0.tv_sec) * 1000.0) +
142 ((t1.tv_nsec - t0.tv_nsec) / 1000000.0);
147 #ifdef _POSIX_MONOTONIC_CLOCK
148 clock_gettime(CLOCK_MONOTONIC, &t);
150 clock_gettime(CLOCK_REALTIME, &t);
156 return t.tv_sec * (
msec_type)1000 + t.tv_nsec / 1000000;
166 #include <sys/timeb.h>
176 return ((t1.time - t0.time) * 1000.0) + (t1.millitm - t0.millitm);
190 return t.time * (
msec_type)1000 + t.millitm;
196 #include <sys/time.h>
202 return ((t1.tv_sec - t0.tv_sec) * 1000.0) +
203 ((t1.tv_usec - t0.tv_usec) / 1000.0);
208 gettimeofday(&t, NULL);
213 return t.tv_sec * (
msec_type)1000 + t.tv_usec / 1000;