00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef TEUCHOS_TIMEMONITOR_HPP
00030 #define TEUCHOS_TIMEMONITOR_HPP
00031
00032
00045 #include "Teuchos_ConfigDefs.hpp"
00046 #include "Teuchos_PerformanceMonitorBase.hpp"
00047 #include "Teuchos_Time.hpp"
00048
00049
00052 #define TEUCHOS_TIMER(funcName, strName) \
00053 static Teuchos::Time& funcName() \
00054 {static Teuchos::RCP<Time> rtn = \
00055 Teuchos::TimeMonitor::getNewCounter(strName); return *rtn;}
00056
00057
00063 #define TEUCHOS_FUNC_TIME_MONITOR_DIFF( FUNCNAME, DIFF ) \
00064 static Teuchos::RCP<Teuchos::Time> DIFF ## blabla_localTimer; \
00065 if(!DIFF ## blabla_localTimer.get()) { \
00066 std::ostringstream oss; \
00067 oss << FUNCNAME; \
00068 DIFF ## blabla_localTimer = Teuchos::TimeMonitor::getNewCounter(oss.str()); \
00069 } \
00070 Teuchos::TimeMonitor DIFF ## blabla_localTimeMonitor(*DIFF ## blabla_localTimer)
00071
00072
00100 #define TEUCHOS_FUNC_TIME_MONITOR( FUNCNAME ) \
00101 TEUCHOS_FUNC_TIME_MONITOR_DIFF( FUNCNAME, main )
00102
00103
00104 namespace Teuchos {
00105
00106
00119 class TEUCHOS_LIB_DLL_EXPORT TimeMonitor : public PerformanceMonitorBase<Time>
00120 {
00121 public:
00122
00125
00127 TimeMonitor(Time& timer, bool reset=false)
00128 : PerformanceMonitorBase<Time>(timer, reset)
00129 {
00130 if (!isRecursiveCall()) counter().start(reset);
00131 }
00132
00134 ~TimeMonitor()
00135 {
00136 if (!isRecursiveCall()) counter().stop();
00137 }
00138
00140
00143
00147 static Teuchos::RCP<Time> getNewTimer(const std::string& name)
00148 {return getNewCounter(name);}
00149
00156 static void zeroOutTimers();
00157
00163 static void summarize(
00164 std::ostream &out=std::cout,
00165 const bool alwaysWriteLocal=false,
00166 const bool writeGlobalStats=true,
00167 const bool writeZeroTimers=true
00168 );
00169
00171
00172 };
00173
00174
00175 }
00176
00177
00178 #endif // TEUCHOS_TIMEMONITOR_H