X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=include%2Ftimer.h;h=2200685db7cf338e698b891ae944824938d6db47;hb=4acfc6927c3e0ad652ed27ade40987703816aab3;hp=78b19e907358e73b768aebb05093ac4ac0b504fe;hpb=4d3663b733242615ba3c5323f7105ef895b3c8bf;p=ctsim.git diff --git a/include/timer.h b/include/timer.h index 78b19e9..2200685 100644 --- a/include/timer.h +++ b/include/timer.h @@ -6,6 +6,10 @@ #include #endif +#ifdef MSVC +#include +#endif + class Timer { public: @@ -25,7 +29,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) @@ -51,6 +55,10 @@ class Timer return 0; return (now.tv_sec + static_cast(now.tv_usec) / 1000000.); +#elif defined(MSVC) + struct _timeb now; + _ftime (&now); + return (now.time + static_cast(now.millitm) / 1000.); #else return 0; #endif @@ -85,7 +93,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) @@ -137,12 +145,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: