13 #include "Teuchos_FancyOStream.hpp"
30 template <
class TagName>
33 , timer_(
rcp(new Teuchos::Time(name, false)))
40 template <
class TagName>
45 GetOStream(
Errors) <<
"MutuallyExclusiveTime::~MutuallyExclusiveTime(): Error: destructor called on a paused timer." << std::endl;
52 template <
class TagName>
62 if (!timerStack_.empty()) {
63 GetOStream(
Debug) <<
"pausing parent timer " << timerStack_.top()->name_ << std::endl;
64 timerStack_.top()->pause();
65 GetOStream(
Debug) <<
"starting child timer " << this->name_ << std::endl;
66 myParent_[this->name_] = timerStack_.top()->name_;
68 GetOStream(
Debug) <<
"starting orphan timer " << this->name_ << std::endl;
74 timerStack_.push(
this);
77 template <
class TagName>
80 GetOStream(
Errors) <<
"MueLu::MutuallyExclusiveTime::stop(): timer is paused. Use resume()" << std::endl;
83 return timer_->stop();
90 double r = timer_->stop();
92 if (!timerStack_.empty()) {
93 GetOStream(
Debug) <<
"resuming timer " << timerStack_.top()->name_ << std::endl;
94 timerStack_.top()->resume();
100 template <
class TagName>
111 template <
class TagName>
119 timer_->start(
false);
123 template <
class TagName>
125 if (timer_->isRunning()) {
129 return timer_->isRunning();
132 template <
class TagName>
138 template <
class TagName>
145 template <
class TagName>
148 template <
class TagName>
153 *fos <<
"Parent Child Map" << std::endl;
154 std::map<std::string, std::string>::const_iterator
iter;
156 *fos <<
"Key: " << iter->first <<
" Value: " << iter->second << std::endl;
160 template <
class TagName>
163 , isPaused_(false) {}
165 template <
class TagName>
172 template <
class TagName>
void TopOfTheStack()
Check if 'this' is the head of the stack.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
~MutuallyExclusiveTime()
Destructor.
Print additional debugging information.
static RCP< MutuallyExclusiveTime< TagName > > getNewTimer(const std::string &name)
Return a new MutuallyExclusiveTime that is registered with the Teuchos::TimeMonitor (for timer summar...
static void PrintParentChildPairs()
Print std::map of (child,parent) pairs for post-run analysis.
void start(bool reset=false)
Starts the timer. If a MutuallyExclusiveTime timer is running, it will be stopped.
static RCP< Time > getNewTimer(const std::string &name)
double stop()
Stops the timer. The previous MutuallyExclusiveTime that has been paused when this timer was started ...
void start(bool reset=false)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
void incrementNumCalls()
Increment the number of times this timer has been called.
RCP< Teuchos::Time > timer_
Using an RCP allows to use Teuchos::TimeMonitor to keep track of the timer.
std::map< std::string, std::string > myParent_
basic_FancyOStream & setOutputToRootOnly(const int rootRank)
void pause()
Pause running timer. Used internally by start().
void resume()
Resume paused timer. Used internally by stop(). Timer is not reset.
This class wraps a Teuchos::Time and maintains a mutually exclusive property between wrapped timers...
Exception throws to report errors in the internal logical of the program.
MutuallyExclusiveTime(const std::string &name, bool startFlag=false)
Constructor.