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
00085 #define TEUCHOS_FUNC_TIME_MONITOR( FUNCNAME ) \
00086 static Teuchos::RCP<Teuchos::Time> blabla_localTimer; \
00087 if(!blabla_localTimer.get()) { \
00088 std::ostringstream oss; \
00089 oss << FUNCNAME; \
00090 blabla_localTimer = Teuchos::TimeMonitor::getNewCounter(oss.str()); \
00091 } \
00092 Teuchos::TimeMonitor blabla_localTimeMonitor(*blabla_localTimer)
00093
00094
00095 namespace Teuchos {
00096
00097
00110 class TimeMonitor : public PerformanceMonitorBase<Time>
00111 {
00112 public:
00113
00116
00118 TimeMonitor(Time& timer, bool reset=false)
00119 : PerformanceMonitorBase<Time>(timer, reset)
00120 {
00121 if (!isRecursiveCall()) counter().start(reset);
00122 }
00123
00125 ~TimeMonitor()
00126 {
00127 if (!isRecursiveCall()) counter().stop();
00128 }
00129
00131
00134
00138 static Teuchos::RCP<Time> getNewTimer(const std::string& name)
00139 {return getNewCounter(name);}
00140
00147 static void zeroOutTimers();
00148
00154 static void summarize(
00155 std::ostream &out=std::cout,
00156 const bool alwaysWriteLocal=false,
00157 const bool writeGlobalStats=true,
00158 const bool writeZeroTimers=true
00159 );
00160
00162
00163 };
00164
00165
00166 }
00167
00168
00169 #endif // TEUCHOS_TIMEMONITOR_H