00001
00011 #include <GKlib.h>
00012
00013
00014
00015
00016
00017
00018
00019 double gk_WClockSeconds(void)
00020 {
00021 #ifdef __GNUC__
00022 struct timeval ctime;
00023
00024 gettimeofday(&ctime, NULL);
00025
00026 return (double)ctime.tv_sec + (double).000001*ctime.tv_usec;
00027 #else
00028 return (double)time(NULL);
00029 #endif
00030 }
00031
00032
00033
00034
00035
00036 double gk_CPUSeconds(void)
00037 {
00038
00039 #ifdef __OPENMPXXXX__
00040 return omp_get_wtime();
00041 #else
00042 #if defined(WIN32) || defined(__MINGW32__)
00043 return((double) clock()/CLOCKS_PER_SEC);
00044 #else
00045 struct rusage r;
00046
00047 getrusage(RUSAGE_SELF, &r);
00048 return ((r.ru_utime.tv_sec + r.ru_stime.tv_sec) + 1.0e-6*(r.ru_utime.tv_usec + r.ru_stime.tv_usec));
00049 #endif
00050 #endif
00051 }
00052