r259: MSVC modifications
[ctsim.git] / include / timer.h
index 781ee941c9fdec87e207a8f945a97d4d2ddbef1c..d0b5d7f508466219ea690dd618d90e8f9a409440 100644 (file)
@@ -2,7 +2,9 @@
 #include "config.h"
 #endif
 
+#ifdef HAVE_SYS_TIME_H
 #include <sys/time.h>
+#endif
 
 class Timer
 {
@@ -23,13 +25,14 @@ 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)
       {
-       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<double>(now.tv_usec) / 1000000.);
+#else
+           return 0;
+#endif
        }
 };
 
@@ -78,13 +85,14 @@ 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)
       {
-       timerEnd ();
+       double t = timerEnd ();
        timerReport (msg);
+       return (t);
       }
 
     virtual void timerReportAllProcesses (const char* const msg)
@@ -121,19 +129,20 @@ 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)
       {
        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: