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) 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 108 #ifdef COIN_DOING_DIFFS 113 #if defined(_MSC_VER) || defined(__MSVCRT__) 119 GetProcessTimes(GetCurrentProcess(), &creation, &exit, &kernel, &user);
120 double t = user.dwHighDateTime * TWO_TO_THE_THIRTYTWO + user.dwLowDateTime;
121 return t / 10000000.0;
123 unsigned int ticksnow;
124 ticksnow = (
unsigned int)clock();
125 cpu_temp = (double)((
double)ticksnow / CLOCKS_PER_SEC);
131 usage.ru_utime.tv_sec = 0;
132 usage.ru_utime.tv_usec = 0;
134 getrusage(RUSAGE_SELF, &usage);
135 cpu_temp =
static_cast< double >(usage.ru_utime.tv_sec);
136 cpu_temp += 1.0e-6 * (
static_cast< double >(usage.ru_utime.tv_usec));
146 #if defined(_MSC_VER) || defined(__MSVCRT__) 151 usage.ru_utime.tv_sec = 0;
152 usage.ru_utime.tv_usec = 0;
154 getrusage(RUSAGE_SELF, &usage);
155 sys_temp =
static_cast< double >(usage.ru_stime.tv_sec);
156 sys_temp += 1.0e-6 * (
static_cast< double >(usage.ru_stime.tv_usec));
166 #if defined(_MSC_VER) || defined(__MSVCRT__) 171 usage.ru_utime.tv_sec = 0;
172 usage.ru_utime.tv_usec = 0;
174 getrusage(RUSAGE_CHILDREN, &usage);
175 cpu_temp =
static_cast< double >(usage.ru_utime.tv_sec);
176 cpu_temp += 1.0e-6 * (
static_cast< double >(usage.ru_utime.tv_usec));
206 #ifdef COIN_COMPILE_WITH_TRACING 207 std::fstream *stream;
212 #ifdef COIN_COMPILE_WITH_TRACING 213 inline bool evaluate(
bool b_tmp)
const 218 (*stream) << i_tmp <<
"\n";
224 inline double evaluate(
double d_tmp)
const 228 (*stream) << d_tmp <<
"\n";
235 inline bool evaluate(
const bool b_tmp)
const 239 inline double evaluate(
const double d_tmp)
const 251 #ifdef COIN_COMPILE_WITH_TRACING
263 #ifdef COIN_COMPILE_WITH_TRACING
270 #ifdef COIN_COMPILE_WITH_TRACING 278 , write_stream(write)
284 CoinTimer(
double lim, std::fstream *s,
bool w)
313 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()