50 #include "Teuchos_FancyOStream.hpp"
67 template <
class TagName>
70 , timer_(
rcp(new Teuchos::Time(name, false)))
77 template <
class TagName>
82 GetOStream(
Errors) <<
"MutuallyExclusiveTime::~MutuallyExclusiveTime(): Error: destructor called on a paused timer." << std::endl;
89 template <
class TagName>
99 if (!timerStack_.empty()) {
100 GetOStream(
Debug) <<
"pausing parent timer " << timerStack_.top()->name_ << std::endl;
101 timerStack_.top()->pause();
102 GetOStream(
Debug) <<
"starting child timer " << this->name_ << std::endl;
103 myParent_[this->name_] = timerStack_.top()->name_;
105 GetOStream(
Debug) <<
"starting orphan timer " << this->name_ << std::endl;
110 timer_->start(reset);
111 timerStack_.push(
this);
114 template <
class TagName>
117 GetOStream(
Errors) <<
"MueLu::MutuallyExclusiveTime::stop(): timer is paused. Use resume()" << std::endl;
120 return timer_->stop();
127 double r = timer_->stop();
129 if (!timerStack_.empty()) {
130 GetOStream(
Debug) <<
"resuming timer " << timerStack_.top()->name_ << std::endl;
131 timerStack_.top()->resume();
137 template <
class TagName>
148 template <
class TagName>
156 timer_->start(
false);
160 template <
class TagName>
162 if (timer_->isRunning()) {
166 return timer_->isRunning();
169 template <
class TagName>
175 template <
class TagName>
182 template <
class TagName>
185 template <
class TagName>
190 *fos <<
"Parent Child Map" << std::endl;
191 std::map<std::string, std::string>::const_iterator
iter;
193 *fos <<
"Key: " << iter->first <<
" Value: " << iter->second << std::endl;
197 template <
class TagName>
200 , isPaused_(false) {}
202 template <
class TagName>
209 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.