Teuchos - Trilinos Tools Package  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Namespaces | Macros | Typedefs
Teuchos_TimeMonitor.hpp File Reference

Scope protection wrapper for Teuchos::Time, with timer reporting functionality. More...

#include "Teuchos_PerformanceMonitorBase.hpp"
#include "Teuchos_ParameterList.hpp"
#include "Teuchos_Comm.hpp"
#include "Teuchos_Time.hpp"
#include "Teuchos_CommandLineProcessor.hpp"

Go to the source code of this file.

Classes

class  Teuchos::TimeMonitor
 A scope-safe timer wrapper class, that can compute global timer statistics. More...
 
class  Teuchos::TimeMonitorSurrogateImpl
 Implementation of TimeMonitorSurrogate that invokes TimeMonitor. More...
 
class  Teuchos::TimeMonitorSurrogateImplInserter
 Injects run-time dependency of a class on TimeMonitor. More...
 

Namespaces

 Teuchos
 The Teuchos namespace contains all of the classes, structs and enums used by Teuchos, as well as a number of utility routines.
 

Macros

#define TEUCHOS_TIMER(funcName, strName)
 Defines a static non-member function that returns a Teuchos timer. More...
 
#define TEUCHOS_FUNC_TIME_MONITOR_DIFF(FUNCNAME, DIFF)
 Defines a timer for a specific function (with differentiator). More...
 
#define TEUCHOS_FUNC_TIME_MONITOR(FUNCNAME)   TEUCHOS_FUNC_TIME_MONITOR_DIFF( FUNCNAME, main )
 Defines a timer for a specific function. More...
 

Typedefs

typedef std::map< std::string,
std::vector< std::pair< double,
double > > > 
Teuchos::stat_map_type
 Global statistics collected from timer data. More...
 

Detailed Description

Scope protection wrapper for Teuchos::Time, with timer reporting functionality.

An instance of the Teuchos::TimeMonitor class wraps a nonconst reference to a Teuchos::Time timer object. TimeMonitor's constructor starts the timer, and its destructor stops the timer. This ensures scope safety of timers, so that no matter how a scope is exited (whether the normal way or when an exception is thrown), a timer started in the scope is stopped when the scope is left.

TimeMonitor also has class methods that create or destroy timers (in such a way that it can track the complete set of created timers on each process) and compute global timer statistics.

Definition in file Teuchos_TimeMonitor.hpp.

Macro Definition Documentation

#define TEUCHOS_TIMER (   funcName,
  strName 
)
Value:
static Teuchos::Time& funcName() \
{static Teuchos::RCP<Time> rtn = \
Teuchos::TimeMonitor::getNewCounter(strName); return *rtn;}
static RCP< Time > getNewCounter(const std::string &name)
Create a new counter with the specified name and add it to a global set of counters of this type...
Wall-clock timer.
Smart reference counting pointer class for automatic garbage collection.

Defines a static non-member function that returns a Teuchos timer.

Warning
Please don't use this macro. It is a bad idea to keep around static RCP objects past return from main().

Definition at line 78 of file Teuchos_TimeMonitor.hpp.

#define TEUCHOS_FUNC_TIME_MONITOR_DIFF (   FUNCNAME,
  DIFF 
)
Value:
static Teuchos::RCP<Teuchos::Time> DIFF ## blabla_localTimer; \
if(!DIFF ## blabla_localTimer.get()) { \
std::ostringstream oss; \
oss << FUNCNAME; \
DIFF ## blabla_localTimer = Teuchos::TimeMonitor::getNewCounter(oss.str()); \
} \
Teuchos::TimeMonitor DIFF ## blabla_localTimeMonitor(*DIFF ## blabla_localTimer)
static RCP< Time > getNewCounter(const std::string &name)
Create a new counter with the specified name and add it to a global set of counters of this type...
T * get() const
Get the raw C++ pointer to the underlying object.
Smart reference counting pointer class for automatic garbage collection.

Defines a timer for a specific function (with differentiator).

Same as TEUCHOS_FUNC_TIME_MONITOR(...) except required when used more than once in the same function (like a block of code).

Warning
Please don't use this macro. It is a bad idea to keep around static RCP objects past return from main().

Definition at line 92 of file Teuchos_TimeMonitor.hpp.

#define TEUCHOS_FUNC_TIME_MONITOR (   FUNCNAME)    TEUCHOS_FUNC_TIME_MONITOR_DIFF( FUNCNAME, main )

Defines a timer for a specific function.

Note that the name of the timer can be formated with stream inserts. For example, we can define a time monitor for a function as follows:

template<typename Scalar>
void foo()
{
);
...
}

The timer can then be printed at the end of the program using any of various class methods, including summarize():

Definition at line 124 of file Teuchos_TimeMonitor.hpp.