Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ElmerCSC
GitHub Repository: ElmerCSC/elmerfem
Path: blob/devel/elmergrid/src/metis-5.1.0/GKlib/timers.c
3206 views
1
/*!
2
\file timers.c
3
\brief Various timing functions
4
5
\date Started 4/12/2007
6
\author George
7
\version\verbatim $Id: timers.c 10711 2011-08-31 22:23:04Z karypis $ \endverbatim
8
*/
9
10
11
#include <GKlib.h>
12
13
#ifdef __GNUC__
14
# include <sys/time.h>
15
#endif
16
17
18
19
/*************************************************************************
20
* This function returns the CPU seconds
21
**************************************************************************/
22
double gk_WClockSeconds(void)
23
{
24
#ifdef __GNUC__
25
26
struct timeval ctime;
27
28
gettimeofday(&ctime, NULL);
29
30
return (double)ctime.tv_sec + (double).000001*ctime.tv_usec;
31
#else
32
return (double)time(NULL);
33
#endif
34
}
35
36
37
/*************************************************************************
38
* This function returns the CPU seconds
39
**************************************************************************/
40
double gk_CPUSeconds(void)
41
{
42
//#ifdef __OPENMP__
43
#ifdef __OPENMPXXXX__
44
return omp_get_wtime();
45
#else
46
#if defined(WIN32) || defined(__MINGW32__)
47
return((double) clock()/CLOCKS_PER_SEC);
48
#else
49
struct rusage r;
50
51
getrusage(RUSAGE_SELF, &r);
52
return ((r.ru_utime.tv_sec + r.ru_stime.tv_sec) + 1.0e-6*(r.ru_utime.tv_usec + r.ru_stime.tv_usec));
53
#endif
54
#endif
55
}
56
57
58