Teuchos - Trilinos Tools Package  Version of the Day
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Teuchos::StackedTimer Class Reference

This class allows one to push and pop timers on and off a stack. More...

#include <Teuchos_StackedTimer.hpp>

Classes

class  LevelTimer
 Timer info at a given level and all the children. More...
 
struct  OutputOptions
 Struct for controlling output options like histograms. More...
 

Public Member Functions

 StackedTimer (const char *name)
 
void start ()
 
void start (const std::string name)
 
void stop (const std::string &name="RootTimer")
 
void incrementCount (int i)
 
double accumulatedTime (const std::string &name="")
 
double accumulatedTimePerUpdate (const std::string &name="")
 
double accumulatedTimePerTimerCall (const std::string &name="")
 
BaseTimer::TimeInfo findTimer (const std::string &name)
 
void report (std::ostream &os, Teuchos::RCP< const Teuchos::Comm< int > > comm, OutputOptions options=OutputOptions())
 

Protected Member Functions

void flatten ()
 
void merge (Teuchos::RCP< const Teuchos::Comm< int > > comm)
 
void collectRemoteData (Teuchos::RCP< const Teuchos::Comm< int > > comm, const OutputOptions &options)
 
double printLevel (std::string prefix, int level, std::ostream &os, std::vector< bool > &printed, double parent_time, const OutputOptions &options)
 

Protected Attributes

LevelTimertop_
 Current level running. More...
 
LevelTimer timer_
 Base timer. More...
 

Detailed Description

This class allows one to push and pop timers on and off a stack.

To use this class one would do something like this

StackedTimer timer(); // construct top level timer timer.start("some comp"); do_work(); timer.start("sub comp"); more_work(); timer.stop(); // stopping sub comp timer.stop(); // stopping comp

timer.stop(); // stopping all timer stuff timer.report(std::cout); // dump to screen

Definition at line 169 of file Teuchos_StackedTimer.hpp.

Constructor & Destructor Documentation

◆ StackedTimer()

Teuchos::StackedTimer::StackedTimer ( const char *  name)
inlineexplicit

Construct a stacked timer

Parameters
nameTop level name of the timer

Definition at line 408 of file Teuchos_StackedTimer.hpp.

Member Function Documentation

◆ start() [1/2]

void Teuchos::StackedTimer::start ( )
inline

Start the base level timer only, used really in testing only

Definition at line 413 of file Teuchos_StackedTimer.hpp.

◆ start() [2/2]

void Teuchos::StackedTimer::start ( const std::string  name)
inline

Start a sublevel timer

Parameters
[in]nameName of the timer you wish to start

Definition at line 423 of file Teuchos_StackedTimer.hpp.

◆ stop()

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

Stop the current top running timer, should be called for the root timer prior to final output

Definition at line 436 of file Teuchos_StackedTimer.hpp.

◆ incrementCount()

void Teuchos::StackedTimer::incrementCount ( int  i)
inline

Increment the iteration count for the running timer

Parameters
[in]iamount to increment the count

Definition at line 450 of file Teuchos_StackedTimer.hpp.

◆ accumulatedTime()

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

Return the accumulated time the named timer has, if name is blank top level timer

Parameters
[in]nameName of the timer to output
Returns
amount of time in seconds

Definition at line 459 of file Teuchos_StackedTimer.hpp.

◆ accumulatedTimePerUpdate()

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

Return the time spent per update at a given level

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

Definition at line 471 of file Teuchos_StackedTimer.hpp.

◆ accumulatedTimePerTimerCall()

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

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

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

Definition at line 482 of file Teuchos_StackedTimer.hpp.

◆ findTimer()

BaseTimer::TimeInfo Teuchos::StackedTimer::findTimer ( const std::string &  name)
inline

Return the time info for a given string (full string name)

Parameters
nameinput string to search for
Returns
Time data

Definition at line 494 of file Teuchos_StackedTimer.hpp.

◆ report()

void Teuchos::StackedTimer::report ( std::ostream &  os,
Teuchos::RCP< const Teuchos::Comm< int > >  comm,
OutputOptions  options = OutputOptions() 
)

Dump all the data from all the MPI ranks to an ostream

Parameters
[in]os- Output stream
[in]comm- Teuchos comm pointer

Definition at line 230 of file Teuchos_StackedTimer.cpp.

◆ flatten()

void Teuchos::StackedTimer::flatten ( )
protected

Flatten the timers into a single array

Definition at line 57 of file Teuchos_StackedTimer.cpp.

◆ merge()

void Teuchos::StackedTimer::merge ( Teuchos::RCP< const Teuchos::Comm< int > >  comm)
protected

Merge all the timers together into a single structure

Parameters
[in]comm- Communicator to use

Definition at line 65 of file Teuchos_StackedTimer.cpp.

◆ collectRemoteData()

void Teuchos::StackedTimer::collectRemoteData ( Teuchos::RCP< const Teuchos::Comm< int > >  comm,
const OutputOptions options 
)
protected

Migrate all the timer data to rank=0 if parallel

Definition at line 72 of file Teuchos_StackedTimer.cpp.

◆ printLevel()

double Teuchos::StackedTimer::printLevel ( std::string  prefix,
int  level,
std::ostream &  os,
std::vector< bool > &  printed,
double  parent_time,
const OutputOptions options 
)
protected

Recursive call to print a level of timer data.

Definition at line 167 of file Teuchos_StackedTimer.cpp.

Member Data Documentation

◆ top_

LevelTimer* Teuchos::StackedTimer::top_
protected

Current level running.

Definition at line 530 of file Teuchos_StackedTimer.hpp.

◆ timer_

LevelTimer Teuchos::StackedTimer::timer_
protected

Base timer.

Definition at line 532 of file Teuchos_StackedTimer.hpp.


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