Teuchos - Trilinos Tools Package  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | List of all members
Teuchos::Time Class Reference

Wall-clock timer. More...

#include <Teuchos_Time.hpp>

Public Member Functions

 Time (const std::string &name, bool start=false)
 Constructor. More...
 
void start (bool reset=false)
 Start the timer, if the timer is enabled (see disable()). More...
 
double stop ()
 Stop the timer, if the timer is enabled (see disable()). More...
 
void disable ()
 "Disable" this timer, so that it ignores calls to start() and stop(). More...
 
void enable ()
 "Enable" this timer, so that it (again) respects calls to start() and stop(). More...
 
bool isEnabled () const
 Whether the timer is enabled (see disable()). More...
 
double totalElapsedTime (bool readCurrentTime=false) const
 The total time in seconds accumulated by this timer. More...
 
void reset ()
 Reset the cummulative time and call count. More...
 
bool isRunning () const
 Whether the timer is currently running. More...
 
const std::string & name () const
 The name of this timer. More...
 
void incrementNumCalls ()
 Increment the number of times this timer has been called, if the timer is enabled (see disable()). More...
 
int numCalls () const
 The number of times this timer has been called while enabled. More...
 

Static Public Member Functions

static double wallTime ()
 Current wall-clock time in seconds. More...
 

Detailed Description

Wall-clock timer.

To time a section of code, place it in between calls to start() and stop(). It is better to access this class through the TimeMonitor class (which see) for exception safety and correct behavior in reentrant code.

If Teuchos is configured with TPL_ENABLE_Valgrind=ON and Teuchos_TIME_MASSIF_SNAPSHOTS=ON Valgrind Massif snapshots are taken before and after Teuchos::Time invocation. The resulting memory profile can be plotted using core/utils/plotMassifMemoryUsage.py

Definition at line 85 of file Teuchos_Time.hpp.

Constructor & Destructor Documentation

Teuchos::Time::Time ( const std::string &  name,
bool  start = false 
)

Constructor.

Parameters
name[in] Name of the timer.
start[in] If true, start the timer upon creating it. By default, the timer only starts running when you call start().

Definition at line 104 of file Teuchos_Time.cpp.

Member Function Documentation

double Teuchos::Time::wallTime ( )
static

Current wall-clock time in seconds.

This is only useful for measuring time intervals. The absolute value returned is measured relative to some arbitrary time in the past.

Definition at line 185 of file Teuchos_Time.cpp.

void Teuchos::Time::start ( bool  reset = false)

Start the timer, if the timer is enabled (see disable()).

Parameters
reset[in] If true, reset the timer's total elapsed time to zero before starting the timer. By default, the timer accumulates the total elapsed time for all start() ... stop() sequences.

Definition at line 113 of file Teuchos_Time.cpp.

double Teuchos::Time::stop ( )

Stop the timer, if the timer is enabled (see disable()).

Definition at line 134 of file Teuchos_Time.cpp.

void Teuchos::Time::disable ( )

"Disable" this timer, so that it ignores calls to start() and stop().

Definition at line 171 of file Teuchos_Time.cpp.

void Teuchos::Time::enable ( )

"Enable" this timer, so that it (again) respects calls to start() and stop().

Definition at line 175 of file Teuchos_Time.cpp.

bool Teuchos::Time::isEnabled ( ) const
inline

Whether the timer is enabled (see disable()).

Definition at line 119 of file Teuchos_Time.hpp.

double Teuchos::Time::totalElapsedTime ( bool  readCurrentTime = false) const

The total time in seconds accumulated by this timer.

Parameters
readCurrentTime[in] If true, return the current elapsed time since the first call to start() when the timer was enabled, whether or not the timer is running or enabled. If false, return the total elapsed time as of the last call to stop() when the timer was enabled.
Note
If start() has never been called when the timer was enabled, and if readCurrentTime is true, this method will return wallTime(), regardless of the actual start time.

Definition at line 159 of file Teuchos_Time.cpp.

void Teuchos::Time::reset ( )

Reset the cummulative time and call count.

Definition at line 166 of file Teuchos_Time.cpp.

bool Teuchos::Time::isRunning ( ) const
inline

Whether the timer is currently running.

"Currently running" means either that start() has been called without an intervening stop() call, or that the timer was created already running and stop() has not since been called.

Definition at line 144 of file Teuchos_Time.hpp.

const std::string& Teuchos::Time::name ( ) const
inline

The name of this timer.

Definition at line 149 of file Teuchos_Time.hpp.

void Teuchos::Time::incrementNumCalls ( )

Increment the number of times this timer has been called, if the timer is enabled (see disable()).

Definition at line 179 of file Teuchos_Time.cpp.

int Teuchos::Time::numCalls ( ) const
inline

The number of times this timer has been called while enabled.

Definition at line 158 of file Teuchos_Time.hpp.


The documentation for this class was generated from the following files: