Teuchos - Trilinos Tools Package Version of the Day
Public Member Functions | Static Public Member Functions
Teuchos::Time Class Reference

Wall-clock timer. More...

#include <Teuchos_Time.hpp>

List of all members.

Public Member Functions

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

Static Public Member Functions

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

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.

Definition at line 79 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 78 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 131 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 84 of file Teuchos_Time.cpp.

double Teuchos::Time::stop ( )

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

Definition at line 93 of file Teuchos_Time.cpp.

void Teuchos::Time::disable ( )

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

Definition at line 117 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 121 of file Teuchos_Time.cpp.

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

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

Definition at line 113 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 105 of file Teuchos_Time.cpp.

void Teuchos::Time::reset ( )

Reset the cummulative time and call count.

Definition at line 112 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 138 of file Teuchos_Time.hpp.

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

The name of this timer.

Definition at line 143 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 125 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 152 of file Teuchos_Time.hpp.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines