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);
440 if( clck->nruns == 0 )
443 switch( clck->clocktype )
451 result =
walltime2sec(clck->data.wallclock.sec, clck->data.wallclock.usec);
461 #if defined(_WIN32) || defined(_WIN64) 462 FILETIME creationtime;
472 switch( clck->clocktype )
475 #if defined(_WIN32) || defined(_WIN64) 476 GetProcessTimes(GetCurrentProcess(), &creationtime, &exittime, &kerneltime, &usertime);
477 result =
cputime2sec(clck->data.cpuclock.user + usertime.dwHighDateTime * 42950 + usertime.dwLowDateTime / 100000L);
480 result =
cputime2sec(clck->data.cpuclock.user + now.tms_utime);
484 #if defined(_WIN32) || defined(_WIN64) 487 gettimeofday(&tp,
NULL);
488 if( tp.tv_usec + clck->data.wallclock.usec > 1000000 )
489 result =
walltime2sec(clck->data.wallclock.sec + tp.tv_sec + 1,
490 (clck->data.wallclock.usec - 1000000) + tp.tv_usec);
492 result =
walltime2sec(clck->data.wallclock.sec + tp.tv_sec,
493 clck->data.wallclock.usec + tp.tv_usec);
504 clck->lasttime = result;
513 assert(clck !=
NULL);
524 assert(clck !=
NULL);
526 SCIPdebugMessage(
"setting time of clock %p (type %d, usedefault=%u, nruns=%d) to %g\n",
527 (
void*)clck, clck->
clocktype, clck->usedefault, clck->nruns, sec);
533 switch( clck->clocktype )
540 sec2walltime(sec, &clck->data.wallclock.sec, &clck->data.wallclock.usec);
549 if( clck->nruns >= 1 )
551 #if defined(_WIN32) || defined(_WIN64) 552 FILETIME creationtime;
562 switch( clck->clocktype )
565 #if defined(_WIN32) || defined(_WIN64) 566 GetProcessTimes(GetCurrentProcess(), &creationtime, &exittime, &kerneltime, &usertime);
567 clck->data.cpuclock.user -= usertime.dwHighDateTime * 42950 + usertime.dwLowDateTime / 100000L;
570 clck->data.cpuclock.user -= now.tms_utime;
575 #if defined(_WIN32) || defined(_WIN64) 576 clck->data.wallclock.sec -= time(
NULL);
578 gettimeofday(&tp,
NULL);
579 if( tp.tv_usec > clck->data.wallclock.usec )
581 clck->data.wallclock.sec -= (tp.tv_sec + 1);
582 clck->data.wallclock.usec += (1000000 - tp.tv_usec);
586 clck->data.wallclock.sec -= tp.tv_sec;
587 clck->data.wallclock.usec -= tp.tv_usec;
605 #if defined(_WIN32) || defined(_WIN64) 612 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