/home/coin/SVN-release/CoinAll-1.1.0/SYMPHONY/include/sym_timemeas.h

Go to the documentation of this file.
00001 /*===========================================================================*/
00002 /*                                                                           */
00003 /* This file is part of the SYMPHONY MILP Solver Framework.                  */
00004 /*                                                                           */
00005 /* SYMPHONY was jointly developed by Ted Ralphs (tkralphs@lehigh.edu) and    */
00006 /* Laci Ladanyi (ladanyi@us.ibm.com).                                        */
00007 /*                                                                           */
00008 /* (c) Copyright 2000-2008 Ted Ralphs. All Rights Reserved.                  */
00009 /*                                                                           */
00010 /* This software is licensed under the Common Public License. Please see     */
00011 /* accompanying file for terms.                                              */
00012 /*                                                                           */
00013 /*===========================================================================*/
00014 
00015 #ifndef __TIMEMEAS_H
00016 #define __TIMEMEAS_H
00017 
00018 #if defined (_MSC_VER) || defined (__MNO_CYGWIN)
00019 #include "sym_win32_time.h"
00020 #else
00021 #include <sys/time.h>
00022 #endif
00023 
00024 #ifdef __DARWIN
00025 #include <sys/resource.h>
00026 #endif
00027 
00028 #include "sym_proto.h"
00029 
00030 #define PRINT_TIME(tm, f) { /* Print the elapsed time in vbctool format*/    \
00031    double elapsed = wall_clock(NULL) - tm->start_time;                       \
00032    int hours, minutes, seconds, msec;                                        \
00033    hours = (int)(elapsed/3600.0);                                            \
00034    elapsed -= hours*3600.0;                                                  \
00035    minutes = (int)(elapsed/60.0);                                            \
00036    elapsed -= minutes*60.0;                                                  \
00037    seconds = (int)elapsed;                                                   \
00038    elapsed -= (double)seconds;                                               \
00039    msec = (int)(elapsed*100.0);                                              \
00040    fprintf(f, "%.2d:%.2d:%.2d:%.2d ", hours, minutes, seconds, msec);         \
00041 }
00042 
00043 #define TVCLEAR(tvp)    (tvp.tv_sec = tvp.tv_usec = 0)
00044 #define PTVCLEAR(tvp)   ((tvp)->tv_sec = (tvp)->tv_usec = 0)
00045 
00046 #define TVISSET(tvp)    (tvp.tv_sec || tvp.tv_usec)
00047 #define PTVISSET(tvp)   ((tvp)->tv_sec || (tvp)->tv_usec)
00048 
00049 #define TVXLTY(xtv, ytv)                                                \
00050    ( (xtv.tv_sec < ytv.tv_sec) ||                                       \
00051      (xtv.tv_sec == ytv.tv_sec && xtv.tv_usec < ytv.tv_usec))
00052 #define PTVXLTY(xtv, ytv)                                                 \
00053    ( ((xtv)->tv_sec < (ytv)->tv_sec) ||                                   \
00054      ((xtv)->tv_sec == (ytv)->tv_sec && (xtv)->tv_usec < (ytv)->tv_usec))
00055 
00056 #define TVXADDY(ztv, xtv, ytv)                                          \
00057      if ((ztv.tv_usec = xtv.tv_usec + ytv.tv_usec) < 1000000) {         \
00058         ztv.tv_sec = xtv.tv_sec + ytv.tv_sec;                           \
00059      } else {                                                           \
00060         ztv.tv_usec -= 1000000;                                         \
00061         ztv.tv_sec = xtv.tv_sec + ytv.tv_sec + 1;                       \
00062      }
00063 #define PTVXADDY(ztv, xtv, ytv)                                          \
00064      if (((ztv)->tv_usec = (xtv)->tv_usec + (ytv)->tv_usec) < 1000000) { \
00065         (ztv)->tv_sec = (xtv)->tv_sec + (ytv)->tv_sec;                   \
00066      } else {                                                            \
00067         (ztv)->tv_usec -= 1000000;                                       \
00068         (ztv)->tv_sec = (xtv)->tv_sec + (ytv)->tv_sec + 1;               \
00069      }
00070 
00071 #define TVXSUBY(ztv, xtv, ytv)                                          \
00072      if (xtv.tv_usec >= ytv.tv_usec) {                                  \
00073         ztv.tv_sec = xtv.tv_sec - ytv.tv_sec;                           \
00074         ztv.tv_usec = xtv.tv_usec - ytv.tv_usec;                        \
00075      } else {                                                           \
00076         ztv.tv_sec = xtv.tv_sec - ytv.tv_sec - 1;                       \
00077         ztv.tv_usec = xtv.tv_usec + 1000000 - ytv.tv_usec;              \
00078      }
00079 #define PTVXSUBY(ztv, xtv, ytv)                                          \
00080      if ((xtv)->tv_usec >= (ytv)->tv_usec) {                             \
00081         (ztv)->tv_sec = (xtv)->tv_sec - (ytv)->tv_sec;                   \
00082         (ztv)->tv_usec = (xtv)->tv_usec - (ytv)->tv_usec;                \
00083      } else {                                                            \
00084         (ztv)->tv_sec = (xtv)->tv_sec - (ytv)->tv_sec - 1;               \
00085         (ztv)->tv_usec = (xtv)->tv_usec + 1000000 - (ytv)->tv_usec;      \
00086      }
00087 
00088 #define TVTODBL(tvp)  ((double)tvp.tv_sec + ((double)tvp.tv_usec)/1000000 )
00089 #define TVPTODBL(tvp) ((double)(tvp)->tv_sec+((double)(tvp)->tv_usec)/1000000)
00090 
00091 #define DBLTOTV(x, tv)                                          \
00092      tv.tv_sec = (int) floor(x);                                \
00093      tv.tv_usec = (int) floor(1000000 * (x - tv.tv_sec));
00094 #define DBLTOPTV(x, tvp)                                                \
00095      (tvp)->tv_sec = (int) floor(x);                                    \
00096      (tvp)->tv_usec = (int) floor(1000000 * (x - (tvp)->tv_sec));
00097 
00098 void start_time PROTO((void));
00099 double used_time PROTO((double *T));
00100 double wall_clock PROTO((double *T));
00101 
00102 #endif

Generated on Sun Nov 14 14:06:42 2010 for Coin-All by  doxygen 1.4.7