00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include "libgomp.h"
00032 #include <unistd.h>
00033 #if TIME_WITH_SYS_TIME
00034 # include <sys/time.h>
00035 # include <time.h>
00036 #else
00037 # if HAVE_SYS_TIME_H
00038 # include <sys/time.h>
00039 # else
00040 # include <time.h>
00041 # endif
00042 #endif
00043
00044
00045 double
00046 omp_get_wtime (void)
00047 {
00048 #ifdef HAVE_CLOCK_GETTIME
00049 struct timespec ts;
00050 # ifdef CLOCK_MONOTONIC
00051 if (clock_gettime (CLOCK_MONOTONIC, &ts) < 0)
00052 # endif
00053 clock_gettime (CLOCK_REALTIME, &ts);
00054 return ts.tv_sec + ts.tv_nsec / 1e9;
00055 #else
00056 struct timeval tv;
00057 gettimeofday (&tv, NULL);
00058 return tv.tv_sec + tv.tv_usec / 1e6;
00059 #endif
00060 }
00061
00062 double
00063 omp_get_wtick (void)
00064 {
00065 #ifdef HAVE_CLOCK_GETTIME
00066 struct timespec ts;
00067 # ifdef CLOCK_MONOTONIC
00068 if (clock_getres (CLOCK_MONOTONIC, &ts) < 0)
00069 # endif
00070 clock_getres (CLOCK_REALTIME, &ts);
00071 return ts.tv_sec + ts.tv_nsec / 1e9;
00072 #else
00073 return 1.0 / sysconf(_SC_CLK_TCK);
00074 #endif
00075 }
00076
00077 ialias (omp_get_wtime)
00078 ialias (omp_get_wtick)