13#include "Teuchos_FancyOStream.hpp"
14#include "Teuchos_RCP.hpp"
15#include "Teuchos_TestForException.hpp"
16#include "Teuchos_Time.hpp"
17#include "Teuchos_TimeMonitor.hpp"
30template <
class TagName>
33 , timer_(rcp(new
Teuchos::Time(name, false)))
37 if (startFlag ==
true) timer_->start();
40template <
class TagName>
45 GetOStream(
Errors) <<
"MutuallyExclusiveTime::~MutuallyExclusiveTime(): Error: destructor called on a paused timer." << std::endl;
52template <
class TagName>
77template <
class TagName>
80 GetOStream(
Errors) <<
"MueLu::MutuallyExclusiveTime::stop(): timer is paused. Use resume()" << std::endl;
83 return timer_->stop();
90 double r = timer_->stop();
100template <
class TagName>
111template <
class TagName>
119 timer_->start(
false);
123template <
class TagName>
125 if (timer_->isRunning()) {
129 return timer_->isRunning();
132template <
class TagName>
138template <
class TagName>
145template <
class TagName>
148template <
class TagName>
151 RCP<Teuchos::FancyOStream> fos = Teuchos::fancyOStream(Teuchos::rcpFromRef(std::cout));
152 fos->setOutputToRootOnly(0);
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;
160template <
class TagName>
163 , isPaused_(false) {}
165template <
class TagName>
167 TEUCHOS_TEST_FOR_EXCEPTION(
timerStack_.empty(),
Exceptions::RuntimeError,
"MueLu::MutuallyExclusiveTime::TopOfTheStack(): timer is not the head of the stack (stack is empty).");
169 TEUCHOS_TEST_FOR_EXCEPTION(!(isRunning() || isPaused()),
Exceptions::RuntimeError,
"MueLu::MutuallyExclusiveTime::TopOfTheStack(): head of the stack timer is neither active nor paused.");
172template <
class TagName>
Exception throws to report errors in the internal logical of the program.
This class wraps a Teuchos::Time and maintains a mutually exclusive property between wrapped timers.
void pause()
Pause running timer. Used internally by start().
void resume()
Resume paused timer. Used internally by stop(). Timer is not reset.
std::string name_
Name of this mutually exclusive timer.
MutuallyExclusiveTime(const std::string &name, bool startFlag=false)
Constructor.
~MutuallyExclusiveTime()
Destructor.
double stop()
Stops the timer. The previous MutuallyExclusiveTime that has been paused when this timer was started ...
static RCP< MutuallyExclusiveTime< TagName > > getNewTimer(const std::string &name)
Return a new MutuallyExclusiveTime that is registered with the Teuchos::TimeMonitor (for timer summar...
void incrementNumCalls()
Increment the number of times this timer has been called.
void start(bool reset=false)
Starts the timer. If a MutuallyExclusiveTime timer is running, it will be stopped.
Teuchos::FancyOStream & GetOStream(MsgType type, int thisProcRankOnly=0) const
Get an output stream for outputting the input message type.
Namespace for MueLu classes and methods.
@ Debug
Print additional debugging information.
std::stack< MutuallyExclusiveTime< TagName > * > MutuallyExclusiveTime< TagName >::timerStack_
std::map< std::string, std::string > myParent_