X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=include%2Ftimer.h;h=78b19e907358e73b768aebb05093ac4ac0b504fe;hb=01ee1e0085970643368d65c38b09008927e24cd5;hp=781ee941c9fdec87e207a8f945a97d4d2ddbef1c;hpb=8c23e6b9615942ac464414b788c5f68b7f66e39d;p=ctsim.git diff --git a/include/timer.h b/include/timer.h index 781ee94..78b19e9 100644 --- a/include/timer.h +++ b/include/timer.h @@ -2,7 +2,9 @@ #include "config.h" #endif +#ifdef HAVE_SYS_TIME_H #include +#endif class Timer { @@ -28,8 +30,9 @@ class Timer virtual double timerEndAndReport (const char* const msg) { - timerEnd (); + double t = timerEnd (); timerReport (msg); + return (t); } double getTimeElapsed (void) const @@ -42,11 +45,15 @@ class Timer double ttime(void) const { +#ifdef HAVE_GETTIMEOFDAY struct timeval now; if (gettimeofday (&now, NULL)) return 0; return (now.tv_sec + static_cast(now.tv_usec) / 1000000.); +#else + return 0; +#endif } }; @@ -83,8 +90,9 @@ class TimerMPI : public Timer virtual double timerEndAndReport (const char* const msg) { - timerEnd (); + double t = timerEnd (); timerReport (msg); + return (t); } virtual void timerReportAllProcesses (const char* const msg) @@ -121,8 +129,9 @@ class TimerCollectiveMPI : public TimerMPI virtual double timerEndAndReport (const char* const msg) { - timerEnd (); + double t = timerEnd (); timerReport (msg); + return (t); } virtual void timerReport (const char* const msg)