34 #if defined(_WIN32) || defined(_WIN64) 37 #include <sys/times.h> 57 clock_t clocks_per_second;
59 #if defined(_WIN32) || defined(_WIN64) 60 clocks_per_second = 100;
63 clocks_per_second = sysconf(_SC_CLK_TCK);
65 clocks_per_second = CLK_TCK;
92 clock_t clocks_per_second;
94 assert(cputime !=
NULL);
96 #if defined(_WIN32) || defined(_WIN64) 97 clocks_per_second = 100;
100 clocks_per_second = sysconf(_SC_CLK_TCK);
102 clocks_per_second = CLK_TCK;
105 *cputime = (clock_t)(sec * clocks_per_second);
116 assert(wallsec !=
NULL);
117 assert(wallusec !=
NULL);
119 *wallsec = (long)sec;
120 *wallusec = (long)((sec - *wallsec) * 1000000.0);
131 assert(clck !=
NULL);
138 assert(clck->
nruns == 0);
162 assert(clck !=
NULL);
175 assert(clck !=
NULL);
189 assert(clck !=
NULL);
200 assert(clck !=
NULL);
202 SCIPdebugMessage(
"initializing clock %p of type %d\n", (
void*)clck, clocktype);
203 clck->enabled =
TRUE;
204 clck->lasttime = 0.0;
213 assert(clck !=
NULL);
216 switch( clck->clocktype )
221 clck->data.cpuclock.user = 0;
224 clck->data.wallclock.sec = 0;
225 clck->data.wallclock.usec = 0;
239 assert(clck !=
NULL);
243 clck->enabled =
TRUE;
251 assert(clck !=
NULL);
255 clck->enabled =
FALSE;
265 assert(clck !=
NULL);
279 assert(clck !=
NULL);
281 SCIPdebugMessage(
"setting type of clock %p (type %d, usedefault=%u) to %d\n",
282 (
void*)clck, clck->
clocktype, clck->usedefault, clocktype);
284 clck->clocktype = clocktype;
295 assert(clck !=
NULL);
302 if( clck->
nruns == 0 )
304 #if defined(_WIN32) || defined(_WIN64) 305 FILETIME creationtime;
316 switch( clck->clocktype )
319 #if defined(_WIN32) || defined(_WIN64) 320 GetProcessTimes(GetCurrentProcess(), &creationtime, &exittime, &kerneltime, &usertime);
321 clck->data.cpuclock.user -= usertime.dwHighDateTime * 42950 + usertime.dwLowDateTime / 100000L;
324 clck->data.cpuclock.user -= now.tms_utime;
326 clck->lasttime =
cputime2sec(clck->data.cpuclock.user);
330 #if defined(_WIN32) || defined(_WIN64) 331 clck->data.wallclock.sec -= time(
NULL);
333 gettimeofday(&tp,
NULL);
334 if( tp.tv_usec > clck->data.wallclock.usec )
336 clck->data.wallclock.sec -= (tp.tv_sec + 1);
337 clck->data.wallclock.usec += (1000000 - tp.tv_usec);
341 clck->data.wallclock.sec -= tp.tv_sec;
342 clck->data.wallclock.usec -= tp.tv_usec;
345 clck->lasttime =
walltime2sec(clck->data.wallclock.sec, clck->data.wallclock.usec);
365 assert(clck !=
NULL);
370 assert(clck->
nruns >= 1);
373 if( clck->
nruns == 0 )
375 #if defined(_WIN32) || defined(_WIN64) 376 FILETIME creationtime;
387 switch( clck->clocktype )
390 #if defined(_WIN32) || defined(_WIN64) 391 GetProcessTimes(GetCurrentProcess(), &creationtime, &exittime, &kerneltime, &usertime);
392 clck->data.cpuclock.user += usertime.dwHighDateTime * 42950 + usertime.dwLowDateTime / 100000L;
395 clck->data.cpuclock.user += now.tms_utime;
400 #if defined(_WIN32) || defined(_WIN64) 401 clck->data.wallclock.sec += time(
NULL);
403 gettimeofday(&tp,
NULL);
404 if( tp.tv_usec + clck->data.wallclock.usec > 1000000 )
406 clck->data.wallclock.sec += (tp.tv_sec + 1);
407 clck->data.wallclock.usec -= (1000000 - tp.tv_usec);
411 clck->data.wallclock.sec += tp.tv_sec;
412 clck->data.wallclock.usec += tp.tv_usec;
431 assert(clck !=
NULL);
433 return (clck->
nruns > 0);
443 assert(clck !=
NULL);
446 SCIPdebugMessage(
"getting time of clock %p (type %d, usedefault=%u, nruns=%d)\n",
447 (
void*)clck, clck->
clocktype, clck->usedefault, clck->nruns);
453 else if( clck->nruns == 0 )
456 switch( clck->clocktype )
464 result =
walltime2sec(clck->data.wallclock.sec, clck->data.wallclock.usec);
474 #if defined(_WIN32) || defined(_WIN64) 475 FILETIME creationtime;
485 switch( clck->clocktype )
488 #if defined(_WIN32) || defined(_WIN64) 489 GetProcessTimes(GetCurrentProcess(), &creationtime, &exittime, &kerneltime, &usertime);
490 result =
cputime2sec(clck->data.cpuclock.user + usertime.dwHighDateTime * 42950 + usertime.dwLowDateTime / 100000L);
493 result =
cputime2sec(clck->data.cpuclock.user + now.tms_utime);
497 #if defined(_WIN32) || defined(_WIN64) 500 gettimeofday(&tp,
NULL);
501 if( tp.tv_usec + clck->data.wallclock.usec > 1000000 )
502 result =
walltime2sec(clck->data.wallclock.sec + tp.tv_sec + 1,
503 (clck->data.wallclock.usec - 1000000) + tp.tv_usec);
505 result =
walltime2sec(clck->data.wallclock.sec + tp.tv_sec,
506 clck->data.wallclock.usec + tp.tv_usec);
520 assert(!
EPSN(result, 1e-12));
524 clck->lasttime = result;
533 assert(clck !=
NULL);
544 assert(clck !=
NULL);
546 SCIPdebugMessage(
"setting time of clock %p (type %d, usedefault=%u, nruns=%d) to %g\n",
547 (
void*)clck, clck->
clocktype, clck->usedefault, clck->nruns, sec);
553 switch( clck->clocktype )
560 sec2walltime(sec, &clck->data.wallclock.sec, &clck->data.wallclock.usec);
569 if( clck->nruns >= 1 )
571 #if defined(_WIN32) || defined(_WIN64) 572 FILETIME creationtime;
582 switch( clck->clocktype )
585 #if defined(_WIN32) || defined(_WIN64) 586 GetProcessTimes(GetCurrentProcess(), &creationtime, &exittime, &kerneltime, &usertime);
587 clck->data.cpuclock.user -= usertime.dwHighDateTime * 42950 + usertime.dwLowDateTime / 100000L;
590 clck->data.cpuclock.user -= now.tms_utime;
595 #if defined(_WIN32) || defined(_WIN64) 596 clck->data.wallclock.sec -= time(
NULL);
598 gettimeofday(&tp,
NULL);
599 if( tp.tv_usec > clck->data.wallclock.usec )
601 clck->data.wallclock.sec -= (tp.tv_sec + 1);
602 clck->data.wallclock.usec += (1000000 - tp.tv_usec);
606 clck->data.wallclock.sec -= tp.tv_sec;
607 clck->data.wallclock.usec -= tp.tv_usec;
625 #if defined(_WIN32) || defined(_WIN64) 632 gettimeofday(&tp,
NULL);
void SCIPclockEnable(SCIP_CLOCK *clck)
void SCIPclockSetType(SCIP_CLOCK *clck, SCIP_CLOCKTYPE clocktype)
static SCIP_Real walltime2sec(long sec, long usec)
internal methods for clocks and timing issues
void SCIPclockDisable(SCIP_CLOCK *clck)
void SCIPclockStop(SCIP_CLOCK *clck, SCIP_SET *set)
enum SCIP_ClockType SCIP_CLOCKTYPE
void SCIPclockStart(SCIP_CLOCK *clck, SCIP_SET *set)
enum SCIP_Retcode SCIP_RETCODE
static void clockSetType(SCIP_CLOCK *clck, SCIP_CLOCKTYPE newtype)
void SCIPclockInit(SCIP_CLOCK *clck, SCIP_CLOCKTYPE clocktype)
void SCIPclockEnableOrDisable(SCIP_CLOCK *clck, SCIP_Bool enable)
#define BMSfreeMemory(ptr)
SCIP_Bool SCIPclockIsRunning(SCIP_CLOCK *clck)
void SCIPclockSetTime(SCIP_CLOCK *clck, SCIP_Real sec)
SCIP_Real SCIPclockGetLastTime(SCIP_CLOCK *clck)
static void sec2walltime(SCIP_Real sec, long *wallsec, long *wallusec)
void SCIPclockReset(SCIP_CLOCK *clck)
SCIP_Real SCIPclockGetTime(SCIP_CLOCK *clck)
internal methods for global SCIP settings
SCIP_RETCODE SCIPclockCreate(SCIP_CLOCK **clck, SCIP_CLOCKTYPE clocktype)
void SCIPclockFree(SCIP_CLOCK **clck)
SCIP_Real SCIPclockGetTimeOfDay(void)
static SCIP_Real cputime2sec(clock_t cputime)
static void sec2cputime(SCIP_Real sec, clock_t *cputime)
static void clockUpdateDefaultType(SCIP_CLOCK *clck, SCIP_CLOCKTYPE defaultclocktype)
datastructures for clocks and timing issues
public methods for message output
#define BMSallocMemory(ptr)
common defines and data types used in all packages of SCIP
memory allocation routines