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

Timer info at a given level and all the children. More...

#include <Teuchos_StackedTimer.hpp>

Inheritance diagram for Teuchos::StackedTimer::LevelTimer:
Teuchos::BaseTimer

Public Member Functions

 LevelTimer ()
 Default constructor, shouldn't be used but needed for std::vector. More...
 
 LevelTimer (int level, const char *name="RootTimer", LevelTimer *parent=nullptr, bool start_timer=true)
 
 LevelTimer (const LevelTimer &src)
 Copy constructor. More...
 
LevelTimerstart (const char *sub_name)
 
LevelTimerstop (const std::string &name="RootTimer")
 
std::string get_full_name () const
 
int countTimers ()
 
double accumulatedTime (const std::string &locate_name="")
 
double accumulatedTimePerUpdate (const std::string &locate_name="")
 
double accumulatedTimePerTimerCall (const std::string &locate_name="")
 
void pack ()
 
LevelTimerunpack (unsigned from)
 
void report (std::ostream &os)
 
const BaseTimerfindBaseTimer (const std::string &name) const
 
BaseTimer::TimeInfo findTimer (const std::string &name, bool &found)
 
- Public Member Functions inherited from Teuchos::BaseTimer
void start ()
 Start a currently stopped timer. More...
 
void stop ()
 Stop a current running timer and accumulate time difference. More...
 
unsigned long long incrementUpdates (unsigned long long count=1)
 Increment the total number of items updated between a start stop. More...
 
double accumulatedTime () const
 Get the total accumulated time since last reset or construction when the timer is running. More...
 
void setAccumulatedTime (double accum=0)
 Setter for accumulated time. More...
 
double accumulatedTimePerUpdate () const
 return the average time per item updated More...
 
double accumulatedTimePerTimerCall () const
 return the average time per timer start/stop More...
 
double difference (const BaseTimer &from) const
 Return the difference between two timers in seconds,. More...
 
void reset ()
 Reset all the timer stats, throws if it is already running. More...
 
bool running () const
 Returns true if the timer is currently accumulating time. More...
 
unsigned long numCalls () const
 Returns the number of calls to start(). More...
 
unsigned long long numUpdates () const
 Returns the number of updates added to this timer. More...
 
void overrideNumCallsForUnitTesting (const unsigned long num_calls)
 Sets the number of calls to start() for this timer. This is only used for unit testing. More...
 
void overrideNumUpdatesForUnitTesting (const unsigned long long num_updates)
 Sets the number of counts for this timer. This is only used for unit testing. More...
 

Protected Member Functions

void splitString (const std::string &locate_name, std::string &first_name, std::string &second_name)
 split a string into two parts split by a '@' if no '@' first gets the full string More...
 

Detailed Description

Timer info at a given level and all the children.

This holds the timer info for the leaf node of a timer stack. It has both its timer info and all the sub leaves bellow it. You can start and stop sub timers, get sub info and dump out things to a ostream

Definition at line 196 of file Teuchos_StackedTimer.hpp.

Constructor & Destructor Documentation

Teuchos::StackedTimer::LevelTimer::LevelTimer ( )

Default constructor, shouldn't be used but needed for std::vector.

Definition at line 12 of file Teuchos_StackedTimer.cpp.

Teuchos::StackedTimer::LevelTimer::LevelTimer ( int  level,
const char *  name = "RootTimer",
LevelTimer parent = nullptr,
bool  start_timer = true 
)
inline

Standard constructor

Parameters
[in]levelInteger level of this timer
[in]nameName for this timer
[in]parentParent of this timer
[in]startbool to start the timer on construction

Definition at line 216 of file Teuchos_StackedTimer.hpp.

Teuchos::StackedTimer::LevelTimer::LevelTimer ( const LevelTimer src)
inline

Copy constructor.

Definition at line 231 of file Teuchos_StackedTimer.hpp.

Member Function Documentation

LevelTimer* Teuchos::StackedTimer::LevelTimer::start ( const char *  sub_name)
inline

Start a sub timer of a given name, create if doesn't exist

Parameters
[in]sub_nameName of subtimer
Returns
Pointer to the sub timer which was started

Definition at line 243 of file Teuchos_StackedTimer.hpp.

LevelTimer* Teuchos::StackedTimer::LevelTimer::stop ( const std::string &  name = "RootTimer")
inline

Stop the current running timer. The timer name is required to verify that you are stopping the current running timer and will error out if the names don't match

Parameters
[in]namethe name of the timer you want to stop, used for matching start only
Returns
parent level timer

Definition at line 260 of file Teuchos_StackedTimer.hpp.

std::string Teuchos::StackedTimer::LevelTimer::get_full_name ( ) const
inline

Return the full name of the timer with each level split by :

Returns
The full name of the timer

Definition at line 272 of file Teuchos_StackedTimer.hpp.

int Teuchos::StackedTimer::LevelTimer::countTimers ( )
inline

Return the number of timers on this level

Returns
the number of timers and sub timers

Definition at line 288 of file Teuchos_StackedTimer.hpp.

double Teuchos::StackedTimer::LevelTimer::accumulatedTime ( const std::string &  locate_name = "")
inline

Return the time spent at a given level

Parameters
[in]locate_namename of subtimer, if blank return current level time
Returns
time in seconds at provided level

Definition at line 306 of file Teuchos_StackedTimer.hpp.

void Teuchos::StackedTimer::LevelTimer::splitString ( const std::string &  locate_name,
std::string &  first_name,
std::string &  second_name 
)
inlineprotected

split a string into two parts split by a '@' if no '@' first gets the full string

Parameters
[in]locate_nameinput string to split
[out]first_namePart of string before the first '@'
[out]second_namepart of string after the first '@'

Definition at line 334 of file Teuchos_StackedTimer.hpp.

double Teuchos::StackedTimer::LevelTimer::accumulatedTimePerUpdate ( const std::string &  locate_name = "")
inline

Return the time spent per update at a given level

Parameters
[in]locate_namename of subtimer, if blank return current level time
Returns
time in seconds per update at provided level

Definition at line 351 of file Teuchos_StackedTimer.hpp.

double Teuchos::StackedTimer::LevelTimer::accumulatedTimePerTimerCall ( const std::string &  locate_name = "")
inline

Return the time spent per timer start/stop pair at a given level

Parameters
[in]locate_namename of subtimer, if blank return current level time
Returns
time in seconds per timer start/stop pair at provided level

Definition at line 370 of file Teuchos_StackedTimer.hpp.

void Teuchos::StackedTimer::LevelTimer::pack ( )

Pack up all the levels into a buffer and mpi send to rank 0

LevelTimer* Teuchos::StackedTimer::LevelTimer::unpack ( unsigned  from)

Unpack the level timer stack from a mpi recv

Parameters
[in]fromrank you are sending from
Returns
pointer to level timer unpacked
void Teuchos::StackedTimer::LevelTimer::report ( std::ostream &  os)

Dump the timer stats in a pretty format to ostream

Parameters
[in/out]os Where are you dumping the stats, stdout??

Definition at line 23 of file Teuchos_StackedTimer.cpp.

const BaseTimer * Teuchos::StackedTimer::LevelTimer::findBaseTimer ( const std::string &  name) const

Return pointer to the BaseTimer corresponding to a given string

Parameters
nameinput string to search for
Returns
pointer to BaseTimer (nullptr if none found)

Definition at line 41 of file Teuchos_StackedTimer.cpp.

BaseTimer::TimeInfo Teuchos::StackedTimer::LevelTimer::findTimer ( const std::string &  name,
bool &  found 
)

Return the time info for a given string

Parameters
nameinput string to search for
setto true on exit if timer was found
Returns
Time data

Definition at line 57 of file Teuchos_StackedTimer.cpp.


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