|
Teuchos - Trilinos Tools Package Version of the Day
|
00001 // @HEADER 00002 // *********************************************************************** 00003 // 00004 // Teuchos: Common Tools Package 00005 // Copyright (2004) Sandia Corporation 00006 // 00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive 00008 // license for use of this work by or on behalf of the U.S. Government. 00009 // 00010 // This library is free software; you can redistribute it and/or modify 00011 // it under the terms of the GNU Lesser General Public License as 00012 // published by the Free Software Foundation; either version 2.1 of the 00013 // License, or (at your option) any later version. 00014 // 00015 // This library is distributed in the hope that it will be useful, but 00016 // WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 // Lesser General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU Lesser General Public 00021 // License along with this library; if not, write to the Free Software 00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00023 // USA 00024 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 00025 // 00026 // *********************************************************************** 00027 // @HEADER 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 } // namespace Teuchos 00176 00177 00178 #endif // TEUCHOS_TIMEMONITOR_H
1.7.4