19 # pragma warning(disable:4786) 22 #if defined(__MACH__) || defined (__FreeBSD__) 25 #if !defined(__MSVCRT__) 26 #include <sys/resource.h> 34 #if 0 // change this to 1 if want to use the win32 API 41 #define TWO_TO_THE_THIRTYTWO 4294967296.0 42 #define DELTA_EPOCH_IN_SECS 11644473600.0 47 GetSystemTimeAsFileTime(&ft);
48 double t = ft.dwHighDateTime * TWO_TO_THE_THIRTYTWO + ft.dwLowDateTime;
49 t = t/10000000.0 - DELTA_EPOCH_IN_SECS;
53 #include <sys/types.h> 54 #include <sys/timeb.h> 57 struct _timeb timebuffer;
58 #pragma warning(disable:4996) 59 _ftime( &timebuffer );
60 #pragma warning(default:4996) 61 return timebuffer.time + timebuffer.millitm/1000.0;
72 gettimeofday(&tv, NULL);
73 return static_cast<double>(tv.tv_sec) + static_cast<int>(tv.tv_usec)/1000000.0;
89 static const double firstCall = callType > 0 ? callType : callTime;
90 return callType < 0 ? firstCall : callTime - firstCall;
103 #define TWO_TO_THE_THIRTYTWO 4294967296.0 109 #if defined(_MSC_VER) || defined(__MSVCRT__) 115 GetProcessTimes(GetCurrentProcess(), &creation, &exit, &kernel, &user);
116 double t = user.dwHighDateTime * TWO_TO_THE_THIRTYTWO + user.dwLowDateTime;
119 unsigned int ticksnow;
120 ticksnow = (
unsigned int)clock();
121 cpu_temp = (double)((
double)ticksnow/CLOCKS_PER_SEC);
127 usage.ru_utime.tv_sec = 0 ;
128 usage.ru_utime.tv_usec = 0 ;
130 getrusage(RUSAGE_SELF,&usage);
131 cpu_temp =
static_cast<double>(usage.ru_utime.tv_sec);
132 cpu_temp += 1.0e-6*(
static_cast<double> (usage.ru_utime.tv_usec));
144 #if defined(_MSC_VER) || defined(__MSVCRT__) 149 usage.ru_utime.tv_sec = 0 ;
150 usage.ru_utime.tv_usec = 0 ;
152 getrusage(RUSAGE_SELF,&usage);
153 sys_temp =
static_cast<double>(usage.ru_stime.tv_sec);
154 sys_temp += 1.0e-6*(
static_cast<double> (usage.ru_stime.tv_usec));
164 #if defined(_MSC_VER) || defined(__MSVCRT__) 169 usage.ru_utime.tv_sec = 0 ;
170 usage.ru_utime.tv_usec = 0 ;
172 getrusage(RUSAGE_CHILDREN,&usage);
173 cpu_temp =
static_cast<double>(usage.ru_utime.tv_sec);
174 cpu_temp += 1.0e-6*(
static_cast<double> (usage.ru_utime.tv_usec));
205 #ifdef COIN_COMPILE_WITH_TRACING 206 std::fstream* stream;
211 #ifdef COIN_COMPILE_WITH_TRACING 212 inline bool evaluate(
bool b_tmp)
const {
216 (*stream) << i_tmp <<
"\n";
222 inline double evaluate(
double d_tmp)
const {
225 (*stream) << d_tmp <<
"\n";
232 inline bool evaluate(
const bool b_tmp)
const {
235 inline double evaluate(
const double d_tmp)
const {
243 start(0), limit(1e100), end(1e100)
244 #ifdef COIN_COMPILE_WITH_TRACING
245 , stream(0), write_stream(true)
252 #ifdef COIN_COMPILE_WITH_TRACING
253 , stream(0), write_stream(true)
257 #ifdef COIN_COMPILE_WITH_TRACING 261 start(0), limit(1e100), end(1e100),
262 stream(s), write_stream(write) {}
266 CoinTimer(
double lim, std::fstream* s,
bool w) :
268 stream(s), write_stream(w) {}
281 return evaluate(start + limit * pct <
CoinCpuTime());
void restart()
Restart the timer (keeping the same time limit)
double timeLeft() const
Return how much time is left on the timer.
double timeElapsed() const
Return how much time has elapsed.
bool isPast(double lim) const
Return whether the given amount of time has elapsed since the timer was started.
static double CoinCpuTime()
bool isExpired() const
Return whether the originally specified time limit has passed since the timer was started...
This class implements a timer that also implements a tracing functionality.
static double CoinCpuTimeJustChildren()
double CoinGetTimeOfDay()
CoinTimer(double lim)
Create a timer with the given time limit and with no tracing.
void reset()
An alternate name for restart()
double CoinWallclockTime(double callType=0)
Query the elapsed wallclock time since the first call to this function.
bool isPastPercent(double pct) const
Return whether the given percentage of the time limit has elapsed since the timer was started...
void reset(double lim)
Reset (and restart) the timer and change its time limit.
CoinTimer()
Default constructor creates a timer with no time limit and no tracing.
static double CoinSysTime()