Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Member Functions | Protected Attributes | 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:
Inheritance graph
[legend]

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 ()
 
void addTimerNames (Array< std::string > &names, unsigned &pos)
 
double accumulatedTime (const std::string &locate_name="")
 
unsigned level () const
 Returns the level of the timer in the stack. More...
 
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
 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...
 

Protected Attributes

unsigned level_
 
std::string name_
 
LevelTimerparent_
 
std::vector< LevelTimersub_timers_
 
- Protected Attributes inherited from Teuchos::BaseTimer
double accumulation_
 
unsigned long count_started_
 
unsigned long long count_updates_
 
Clock::time_point start_time_
 
bool running_
 

Additional Inherited Members

- Public Types inherited from Teuchos::BaseTimer
using Clock = std::chrono::high_resolution_clock
 

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 203 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 22 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 223 of file Teuchos_StackedTimer.hpp.

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

Copy constructor.

Definition at line 238 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 250 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 267 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 279 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 295 of file Teuchos_StackedTimer.hpp.

void Teuchos::StackedTimer::LevelTimer::addTimerNames ( Array< std::string > &  names,
unsigned &  pos 
)
inline

Definition at line 302 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 313 of file Teuchos_StackedTimer.hpp.

unsigned Teuchos::StackedTimer::LevelTimer::level ( ) const
inline

Returns the level of the timer in the stack.

Definition at line 335 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 345 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 362 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 381 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]osWhere are you dumping the stats, stdout??

Definition at line 33 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 51 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 67 of file Teuchos_StackedTimer.cpp.

Member Data Documentation

unsigned Teuchos::StackedTimer::LevelTimer::level_
protected

Definition at line 208 of file Teuchos_StackedTimer.hpp.

std::string Teuchos::StackedTimer::LevelTimer::name_
protected

Definition at line 209 of file Teuchos_StackedTimer.hpp.

LevelTimer* Teuchos::StackedTimer::LevelTimer::parent_
protected

Definition at line 210 of file Teuchos_StackedTimer.hpp.

std::vector<LevelTimer> Teuchos::StackedTimer::LevelTimer::sub_timers_
protected

Definition at line 211 of file Teuchos_StackedTimer.hpp.


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