24 #if defined(_WIN32) || defined(_WIN64) 27 #include <sys/times.h> 47 clock_t clocks_per_second;
49 #if defined(_WIN32) || defined(_WIN64) 50 clocks_per_second = 100;
53 clocks_per_second = sysconf(_SC_CLK_TCK);
55 clocks_per_second = CLK_TCK;
82 clock_t clocks_per_second;
84 assert(cputime != NULL);
86 #if defined(_WIN32) || defined(_WIN64) 87 clocks_per_second = 100;
90 clocks_per_second = sysconf(_SC_CLK_TCK);
92 clocks_per_second = CLK_TCK;
95 *cputime = (clock_t)(sec * clocks_per_second);
106 assert(wallsec != NULL);
107 assert(wallusec != NULL);
109 *wallsec = (long)sec;
110 *wallusec = (long)((sec - *wallsec) * 1000000.0);
121 assert(clck != NULL);
128 assert(clck->
nruns == 0);
152 assert(clck != NULL);
165 assert(clck != NULL);
179 assert(clck != NULL);
190 assert(clck != NULL);
192 SCIPdebugMessage(
"initializing clock %p of type %d\n", (
void*)clck, clocktype);
193 clck->enabled =
TRUE;
194 clck->lasttime = 0.0;
203 assert(clck != NULL);
206 switch( clck->clocktype )
211 clck->data.cpuclock.user = 0;
214 clck->data.wallclock.sec = 0;
215 clck->data.wallclock.usec = 0;
229 assert(clck != NULL);
233 clck->enabled =
TRUE;
241 assert(clck != NULL);
245 clck->enabled =
FALSE;
255 assert(clck != NULL);
269 assert(clck != NULL);
271 SCIPdebugMessage(
"setting type of clock %p (type %d, usedefault=%u) to %d\n",
272 (
void*)clck, clck->
clocktype, clck->usedefault, clocktype);
274 clck->clocktype = clocktype;
285 assert(clck != NULL);
288 if( set->time_enabled && clck->
enabled )
292 if( clck->
nruns == 0 )
294 #if defined(_WIN32) || defined(_WIN64) 295 FILETIME creationtime;
306 switch( clck->clocktype )
309 #if defined(_WIN32) || defined(_WIN64) 310 GetProcessTimes(GetCurrentProcess(), &creationtime, &exittime, &kerneltime, &usertime);
311 clck->data.cpuclock.user -= usertime.dwHighDateTime * 42950 + usertime.dwLowDateTime / 100000L;
314 clck->data.cpuclock.user -= now.tms_utime;
316 clck->lasttime =
cputime2sec(clck->data.cpuclock.user);
320 #if defined(_WIN32) || defined(_WIN64) 321 clck->data.wallclock.sec -= time(NULL);
323 gettimeofday(&tp, NULL);
324 if( tp.tv_usec > clck->data.wallclock.usec )
326 clck->data.wallclock.sec -= (tp.tv_sec + 1);
327 clck->data.wallclock.usec += (1000000 - tp.tv_usec);
331 clck->data.wallclock.sec -= tp.tv_sec;
332 clck->data.wallclock.usec -= tp.tv_usec;
335 clck->lasttime =
walltime2sec(clck->data.wallclock.sec, clck->data.wallclock.usec);
355 assert(clck != NULL);
358 if( set->time_enabled && clck->
enabled )
360 assert(clck->
nruns >= 1);
363 if( clck->
nruns == 0 )
365 #if defined(_WIN32) || defined(_WIN64) 366 FILETIME creationtime;
377 switch( clck->clocktype )
380 #if defined(_WIN32) || defined(_WIN64) 381 GetProcessTimes(GetCurrentProcess(), &creationtime, &exittime, &kerneltime, &usertime);
382 clck->data.cpuclock.user += usertime.dwHighDateTime * 42950 + usertime.dwLowDateTime / 100000L;
385 clck->data.cpuclock.user += now.tms_utime;
390 #if defined(_WIN32) || defined(_WIN64) 391 clck->data.wallclock.sec += time(NULL);
393 gettimeofday(&tp, NULL);
394 if( tp.tv_usec + clck->data.wallclock.usec > 1000000 )
396 clck->data.wallclock.sec += (tp.tv_sec + 1);
397 clck->data.wallclock.usec -= (1000000 - tp.tv_usec);
401 clck->data.wallclock.sec += tp.tv_sec;
402 clck->data.wallclock.usec += tp.tv_usec;
421 assert(clck != NULL);
423 return (clck->
nruns > 0);
433 assert(clck != NULL);
436 SCIPdebugMessage(
"getting time of clock %p (type %d, usedefault=%u, nruns=%d)\n",
437 (
void*)clck, clck->
clocktype, clck->usedefault, clck->nruns);
439 if( clck->nruns == 0 )
442 switch( clck->clocktype )
450 result =
walltime2sec(clck->data.wallclock.sec, clck->data.wallclock.usec);
460 #if defined(_WIN32) || defined(_WIN64) 461 FILETIME creationtime;
471 switch( clck->clocktype )
474 #if defined(_WIN32) || defined(_WIN64) 475 GetProcessTimes(GetCurrentProcess(), &creationtime, &exittime, &kerneltime, &usertime);
476 result =
cputime2sec(clck->data.cpuclock.user + usertime.dwHighDateTime * 42950 + usertime.dwLowDateTime / 100000L);
479 result =
cputime2sec(clck->data.cpuclock.user + now.tms_utime);
483 #if defined(_WIN32) || defined(_WIN64) 484 result =
walltime2sec(clck->data.wallclock.sec + time(NULL), 0);
486 gettimeofday(&tp, NULL);
487 if( tp.tv_usec + clck->data.wallclock.usec > 1000000 )
488 result =
walltime2sec(clck->data.wallclock.sec + tp.tv_sec + 1,
489 (clck->data.wallclock.usec - 1000000) + tp.tv_usec);
491 result =
walltime2sec(clck->data.wallclock.sec + tp.tv_sec,
492 clck->data.wallclock.usec + tp.tv_usec);
503 clck->lasttime = result;
512 assert(clck != NULL);
523 assert(clck != NULL);
525 SCIPdebugMessage(
"setting time of clock %p (type %d, usedefault=%u, nruns=%d) to %g\n",
526 (
void*)clck, clck->
clocktype, clck->usedefault, clck->nruns, sec);
532 switch( clck->clocktype )
539 sec2walltime(sec, &clck->data.wallclock.sec, &clck->data.wallclock.usec);
548 if( clck->nruns >= 1 )
550 #if defined(_WIN32) || defined(_WIN64) 551 FILETIME creationtime;
561 switch( clck->clocktype )
564 #if defined(_WIN32) || defined(_WIN64) 565 GetProcessTimes(GetCurrentProcess(), &creationtime, &exittime, &kerneltime, &usertime);
566 clck->data.cpuclock.user -= usertime.dwHighDateTime * 42950 + usertime.dwLowDateTime / 100000L;
569 clck->data.cpuclock.user -= now.tms_utime;
574 #if defined(_WIN32) || defined(_WIN64) 575 clck->data.wallclock.sec -= time(NULL);
577 gettimeofday(&tp, NULL);
578 if( tp.tv_usec > clck->data.wallclock.usec )
580 clck->data.wallclock.sec -= (tp.tv_sec + 1);
581 clck->data.wallclock.usec += (1000000 - tp.tv_usec);
585 clck->data.wallclock.sec -= tp.tv_sec;
586 clck->data.wallclock.usec -= tp.tv_usec;
604 #if defined(_WIN32) || defined(_WIN64) 611 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