X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=include%2Ftimer.h;h=e938ae91936411919f34ce030a9b47c93bec1577;hb=ca7c001fce978b680543f8338a404b8c0701a935;hp=78b19e907358e73b768aebb05093ac4ac0b504fe;hpb=4d3663b733242615ba3c5323f7105ef895b3c8bf;p=ctsim.git diff --git a/include/timer.h b/include/timer.h index 78b19e9..e938ae9 100644 --- a/include/timer.h +++ b/include/timer.h @@ -1,3 +1,30 @@ +/***************************************************************************** +** FILE IDENTIFICATION +** +** Name: timer.h +** Purpose: Header file for Timer class +** Author: Kevin Rosenberg +** Date Started: Sep 2000 +** +** This is part of the CTSim program +** Copyright (c) 1983-2001 Kevin Rosenberg +** +** $Id: timer.h,v 1.6 2001/01/28 19:10:18 kevin Exp $ +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License (version 2) as +** published by the Free Software Foundation. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +******************************************************************************/ + #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -6,6 +33,10 @@ #include #endif +#ifdef MSVC +#include +#endif + class Timer { public: @@ -25,7 +56,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 +82,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 +120,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 +172,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: