Teuchos_TimeMonitor.hpp

Go to the documentation of this file.
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 
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 } // namespace Teuchos
00167 
00168 
00169 #endif // TEUCHOS_TIMEMONITOR_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on Tue Oct 20 10:14:01 2009 for Teuchos Package Browser (Single Doxygen Collection) by  doxygen 1.6.1