1 /*! @file superlu_timer.c
2  * \brief Returns the time used
3  *
4  * <pre>
5  * Purpose
6  * =======
7  *
8  * Returns the time in seconds used by the process.
9  *
10  * Note: the timer function call is machine dependent. Use conditional
11  *       compilation to choose the appropriate function.
12  * </pre>
13  */
14 
15 
16 #ifdef SUN
17 /*
18  * 	It uses the system call gethrtime(3C), which is accurate to
19  *	nanoseconds.
20 */
21 #include <sys/time.h>
22 
SuperLU_timer_()23 double SuperLU_timer_() {
24     return ( (double)gethrtime() / 1e9 );
25 }
26 
27 #elif _WIN32
28 
29 #include <time.h>
30 
SuperLU_timer_()31 double SuperLU_timer_()
32 {
33     clock_t t;
34     t=clock();
35 
36     return ((double)t)/CLOCKS_PER_SEC;
37 }
38 
39 #else
40 
41 #ifndef NO_TIMER
42 #include <sys/types.h>
43 #include <sys/times.h>
44 #include <time.h>
45 #include <sys/time.h>
46 #endif
47 
48 #ifndef CLK_TCK
49 #define CLK_TCK 60
50 #endif
51 /*! \brief Timer function
52  */
SuperLU_timer_()53 double SuperLU_timer_()
54 {
55 #ifdef NO_TIMER
56     /* no sys/times.h on WIN32 */
57     double tmp;
58     tmp = 0.0;
59 #else
60     struct tms use;
61     double tmp;
62     times(&use);
63     tmp = use.tms_utime;
64     tmp += use.tms_stime;
65 #endif
66     return (double)(tmp) / CLK_TCK;
67 }
68 
69 #endif
70 
71