25 #if defined(_WIN32) || defined(_WIN64) 28 #include <sys/times.h> 48 clock_t clocks_per_second;
50 #if defined(_WIN32) || defined(_WIN64) 51 clocks_per_second = 100;
54 clocks_per_second = sysconf(_SC_CLK_TCK);
56 clocks_per_second = CLK_TCK;
83 clock_t clocks_per_second;
85 assert(cputime !=
NULL);
87 #if defined(_WIN32) || defined(_WIN64) 88 clocks_per_second = 100;
91 clocks_per_second = sysconf(_SC_CLK_TCK);
93 clocks_per_second = CLK_TCK;
96 *cputime = (clock_t)(sec * clocks_per_second);
107 assert(wallsec !=
NULL);
108 assert(wallusec !=
NULL);
110 *wallsec = (long)sec;
111 *wallusec = (long)((sec - *wallsec) * 1000000.0);
122 assert(clck !=
NULL);
129 assert(clck->
nruns == 0);
153 assert(clck !=
NULL);
166 assert(clck !=
NULL);
180 assert(clck !=
NULL);
191 assert(clck !=
NULL);
193 SCIPdebugMessage(
"initializing clock %p of type %d\n", (
void*)clck, clocktype);
194 clck->enabled =
TRUE;
195 clck->lasttime = 0.0;
204 assert(clck !=
NULL);
207 switch( clck->clocktype )
212 clck->data.cpuclock.user = 0;
215 clck->data.wallclock.sec = 0;
216 clck->data.wallclock.usec = 0;
230 assert(clck !=
NULL);
234 clck->enabled =
TRUE;
242 assert(clck !=
NULL);
246 clck->enabled =
FALSE;
256 assert(clck !=
NULL);
270 assert(clck !=
NULL);
272 SCIPdebugMessage(
"setting type of clock %p (type %d, usedefault=%u) to %d\n",
273 (
void*)clck, clck->
clocktype, clck->usedefault, clocktype);
275 clck->clocktype = clocktype;
286 assert(clck !=
NULL);
293 if( clck->
nruns == 0 )
295 #if defined(_WIN32) || defined(_WIN64) 296 FILETIME creationtime;
307 switch( clck->clocktype )
310 #if defined(_WIN32) || defined(_WIN64) 311 GetProcessTimes(GetCurrentProcess(), &creationtime, &exittime, &kerneltime, &usertime);
312 clck->data.cpuclock.user -= usertime.dwHighDateTime * 42950 + usertime.dwLowDateTime / 100000L;
315 clck->data.cpuclock.user -= now.tms_utime;
317 clck->lasttime =
cputime2sec(clck->data.cpuclock.user);
321 #if defined(_WIN32) || defined(_WIN64) 322 clck->data.wallclock.sec -= time(
NULL);
324 gettimeofday(&tp,
NULL);
325 if( tp.tv_usec > clck->data.wallclock.usec )
327 clck->data.wallclock.sec -= (tp.tv_sec + 1);
328 clck->data.wallclock.usec += (1000000 - tp.tv_usec);
332 clck->data.wallclock.sec -= tp.tv_sec;
333 clck->data.wallclock.usec -= tp.tv_usec;
336 clck->lasttime =
walltime2sec(clck->data.wallclock.sec, clck->data.wallclock.usec);
356 assert(clck !=
NULL);
361 assert(clck->
nruns >= 1);
364 if( clck->
nruns == 0 )
366 #if defined(_WIN32) || defined(_WIN64) 367 FILETIME creationtime;
378 switch( clck->clocktype )
381 #if defined(_WIN32) || defined(_WIN64) 382 GetProcessTimes(GetCurrentProcess(), &creationtime, &exittime, &kerneltime, &usertime);
383 clck->data.cpuclock.user += usertime.dwHighDateTime * 42950 + usertime.dwLowDateTime / 100000L;
386 clck->data.cpuclock.user += now.tms_utime;
391 #if defined(_WIN32) || defined(_WIN64) 392 clck->data.wallclock.sec += time(
NULL);
394 gettimeofday(&tp,
NULL);
395 if( tp.tv_usec + clck->data.wallclock.usec > 1000000 )
397 clck->data.wallclock.sec += (tp.tv_sec + 1);
398 clck->data.wallclock.usec -= (1000000 - tp.tv_usec);
402 clck->data.wallclock.sec += tp.tv_sec;
403 clck->data.wallclock.usec += tp.tv_usec;
422 assert(clck !=
NULL);
424 return (clck->
nruns > 0);
434 assert(clck !=
NULL);
437 SCIPdebugMessage(
"getting time of clock %p (type %d, usedefault=%u, nruns=%d)\n",
438 (
void*)clck, clck->
clocktype, clck->usedefault, clck->nruns);
444 else if( clck->nruns == 0 )
447 switch( clck->clocktype )
455 result =
walltime2sec(clck->data.wallclock.sec, clck->data.wallclock.usec);
465 #if defined(_WIN32) || defined(_WIN64) 466 FILETIME creationtime;
476 switch( clck->clocktype )
479 #if defined(_WIN32) || defined(_WIN64) 480 GetProcessTimes(GetCurrentProcess(), &creationtime, &exittime, &kerneltime, &usertime);
481 result =
cputime2sec(clck->data.cpuclock.user + usertime.dwHighDateTime * 42950 + usertime.dwLowDateTime / 100000L);
484 result =
cputime2sec(clck->data.cpuclock.user + now.tms_utime);
488 #if defined(_WIN32) || defined(_WIN64) 491 gettimeofday(&tp,
NULL);
492 if( tp.tv_usec + clck->data.wallclock.usec > 1000000 )
493 result =
walltime2sec(clck->data.wallclock.sec + tp.tv_sec + 1,
494 (clck->data.wallclock.usec - 1000000) + tp.tv_usec);
496 result =
walltime2sec(clck->data.wallclock.sec + tp.tv_sec,
497 clck->data.wallclock.usec + tp.tv_usec);
508 clck->lasttime = result;
517 assert(clck !=
NULL);
528 assert(clck !=
NULL);
530 SCIPdebugMessage(
"setting time of clock %p (type %d, usedefault=%u, nruns=%d) to %g\n",
531 (
void*)clck, clck->
clocktype, clck->usedefault, clck->nruns, sec);
537 switch( clck->clocktype )
544 sec2walltime(sec, &clck->data.wallclock.sec, &clck->data.wallclock.usec);
553 if( clck->nruns >= 1 )
555 #if defined(_WIN32) || defined(_WIN64) 556 FILETIME creationtime;
566 switch( clck->clocktype )
569 #if defined(_WIN32) || defined(_WIN64) 570 GetProcessTimes(GetCurrentProcess(), &creationtime, &exittime, &kerneltime, &usertime);
571 clck->data.cpuclock.user -= usertime.dwHighDateTime * 42950 + usertime.dwLowDateTime / 100000L;
574 clck->data.cpuclock.user -= now.tms_utime;
579 #if defined(_WIN32) || defined(_WIN64) 580 clck->data.wallclock.sec -= time(
NULL);
582 gettimeofday(&tp,
NULL);
583 if( tp.tv_usec > clck->data.wallclock.usec )
585 clck->data.wallclock.sec -= (tp.tv_sec + 1);
586 clck->data.wallclock.usec += (1000000 - tp.tv_usec);
590 clck->data.wallclock.sec -= tp.tv_sec;
591 clck->data.wallclock.usec -= tp.tv_usec;
609 #if defined(_WIN32) || defined(_WIN64) 616 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