X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=include%2Ftimer.h;h=d0b5d7f508466219ea690dd618d90e8f9a409440;hb=9f7d379c2b03f3c09907cfd885072433e0428042;hp=705627f703dd561a8b63555343843a686ddf3526;hpb=3fba6928127cd65870bdcd96c8114ad5894247ae;p=ctsim.git diff --git a/include/timer.h b/include/timer.h index 705627f..d0b5d7f 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 { @@ -23,7 +25,7 @@ class Timer virtual void timerReport (const char* const msg) const { - cout << msg << ": " << m_timeElapsed << " seconds" << endl; + std::cout << msg << ": " << m_timeElapsed << " seconds" << std::endl; } virtual double timerEndAndReport (const char* const msg) @@ -43,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 } }; @@ -79,7 +85,7 @@ class TimerMPI : public Timer virtual void timerReport (const char* const msg) { if (m_comm.Get_rank() == 0) - cout << msg << ": " << m_timeElapsed << " seconds" << endl; + std::cout << msg << ": " << m_timeElapsed << " seconds" << std::endl; } virtual double timerEndAndReport (const char* const msg) @@ -131,12 +137,12 @@ class TimerCollectiveMPI : public TimerMPI virtual void timerReport (const char* const msg) { if (m_comm.Get_rank() == 0) - cout << msg << " " << "Minimum=" << m_timeMin << ", Maximum=" << m_timeMax << " seconds" << endl; + std::cout << msg << " " << "Minimum=" << m_timeMin << ", Maximum=" << m_timeMax << " seconds" << std::endl; } virtual void timerReportAllProcesses (const char* const msg) { - cout << msg << ": " << "Minimum=" << m_timeMin << ", Maximum=" << m_timeMax << " seconds (Rank " << m_comm.Get_rank() << ")" << endl; + std::cout << msg << ": " << "Minimum=" << m_timeMin << ", Maximum=" << m_timeMax << " seconds (Rank " << m_comm.Get_rank() << ")" << std::endl; } private: