Main Page
Namespaces
Classes
Files
File List
File Members
src
GetTime.c
Go to the documentation of this file.
1
#define HAVE_GETRUSAGE
2
/* Undefine if you don't have the getrusage function */
3
/* #undef HAVE_GETRUSAGE */
4
5
/*
6
* The GetTime function is used to measure execution time.
7
*
8
* The function is called before and after the code to be
9
* measured. The difference between the second and the
10
* first call gives the number of seconds spent in executing
11
* the code.
12
*
13
* If the system call getrusage() is supported, the difference
14
* gives the user time used; otherwise, the accounted real time.
15
*/
16
17
#ifdef HAVE_GETRUSAGE
18
#include <sys/time.h>
19
#include <sys/resource.h>
20
21
double
GetTime
()
22
{
23
struct
rusage ru;
24
getrusage(RUSAGE_SELF, &ru);
25
return
ru.ru_utime.tv_sec + ru.ru_utime.tv_usec / 1000000.0;
26
}
27
28
#else
29
30
#include <
time.h
>
31
32
double
GetTime
()
33
{
34
return
(
double
) clock() / CLOCKS_PER_SEC;
35
}
36
37
#endif
time.h
GetTime
double GetTime()
Definition:
GetTime.c:21
glkh_solver
Author(s): Francisco Suarez-Ruiz
autogenerated on Mon Jun 10 2019 13:50:26