28 |
*/ |
*/ |
29 |
|
|
30 |
#include <time.h> |
#include <time.h> |
31 |
#include "utilities/ascConfig.h" |
#include <utilities/ascConfig.h> |
32 |
#include "general/tm_time.h" |
#include <utilities/ascPanic.h> |
33 |
|
#include "tm_time.h" |
34 |
|
|
35 |
double tm_cpu_time() |
static boolean f_first = TRUE; |
36 |
|
|
37 |
|
double tm_cpu_time(void) |
38 |
{ |
{ |
|
static boolean first = TRUE; |
|
39 |
static clock_t ref; |
static clock_t ref; |
40 |
static double dref; |
static double dref; |
41 |
static double dcps; |
static double dcps; |
42 |
clock_t now; |
clock_t now; |
43 |
double dnow; |
double dnow; |
44 |
|
|
45 |
if( first ) { |
if( f_first ) { |
46 |
dcps = (double) CLOCKS_PER_SEC; |
dcps = (double) CLOCKS_PER_SEC; |
47 |
ref = clock(); |
ref = clock(); |
48 |
dref = (double) ref; |
dref = (double) ref; |
49 |
first = FALSE; |
f_first = FALSE; |
50 |
} |
} |
51 |
now = clock(); |
now = clock(); |
52 |
dnow = (double) now; |
dnow = (double) now; |
54 |
return( (dnow - dref)/dcps ); |
return( (dnow - dref)/dcps ); |
55 |
} |
} |
56 |
|
|
57 |
|
double tm_reset_cpu_time(void) |
58 |
|
{ |
59 |
|
f_first = TRUE; |
60 |
|
return tm_cpu_time(); |
61 |
|
} |
62 |
|
|
63 |
void tm_cpu_time_ftn_(double *t) |
void tm_cpu_time_ftn_(double *t) |
64 |
{ |
{ |
65 |
|
asc_assert(NULL != t); |
66 |
*t = tm_cpu_time(); |
*t = tm_cpu_time(); |
67 |
} |
} |
68 |
|
|
69 |
void aftime_(double *t) |
void aftime_(double *t) |
70 |
{ |
{ |
71 |
|
asc_assert(NULL != t); |
72 |
*t = tm_cpu_time(); |
*t = tm_cpu_time(); |
73 |
} |
} |
74 |
|
|
75 |
void tm_cpu_time_ftn(double *t) |
void tm_cpu_time_ftn(double *t) |
76 |
{ |
{ |
77 |
|
asc_assert(NULL != t); |
78 |
*t = tm_cpu_time(); |
*t = tm_cpu_time(); |
79 |
} |
} |
80 |
|
|
81 |
void aftime(double *t) |
void aftime(double *t) |
82 |
{ |
{ |
83 |
|
asc_assert(NULL != t); |
84 |
*t = tm_cpu_time(); |
*t = tm_cpu_time(); |
85 |
} |
} |
86 |
|
|
87 |
void TM_CPU_TIME_FTN(double *t) |
void TM_CPU_TIME_FTN(double *t) |
88 |
{ |
{ |
89 |
|
asc_assert(NULL != t); |
90 |
*t = tm_cpu_time(); |
*t = tm_cpu_time(); |
91 |
} |
} |
92 |
|
|
93 |
void AFTIME(double *t) |
void AFTIME(double *t) |
94 |
{ |
{ |
95 |
|
asc_assert(NULL != t); |
96 |
*t = tm_cpu_time(); |
*t = tm_cpu_time(); |
97 |
} |
} |