50 #include "Teuchos_FancyOStream.hpp"
51 #include "Teuchos_RCP.hpp"
52 #include "Teuchos_TestForException.hpp"
53 #include "Teuchos_Time.hpp"
54 #include "Teuchos_TimeMonitor.hpp"
67 template <
class TagName>
70 timer_(rcp(new
Teuchos::Time(name, false))),
74 if (startFlag ==
true)
timer_->start();
77 template <
class TagName>
82 GetOStream(
Errors) <<
"MutuallyExclusiveTime::~MutuallyExclusiveTime(): Error: destructor called on a paused timer." << std::endl;
89 template <
class TagName>
91 TEUCHOS_TEST_FOR_EXCEPTION(isPaused(),
Exceptions::RuntimeError,
"MueLu::MutuallyExclusiveTime::start(): timer is paused. Use resume().");
93 if (isRunning()) {
return; }
97 if (!timerStack_.empty()) {
98 GetOStream(
Debug) <<
"pausing parent timer " << timerStack_.top()->name_ << std::endl;
99 timerStack_.top()->pause();
100 GetOStream(
Debug) <<
"starting child timer " << this->name_ << std::endl;
101 myParent_[this->name_] = timerStack_.top()->name_;
103 GetOStream(
Debug) <<
"starting orphan timer " << this->name_ << std::endl;
108 timer_->start(reset);
109 timerStack_.push(
this);
112 template <
class TagName>
115 GetOStream(
Errors) <<
"MueLu::MutuallyExclusiveTime::stop(): timer is paused. Use resume()" << std::endl;
117 if (!isRunning()) {
return timer_->stop(); }
123 double r = timer_->stop();
125 if (!timerStack_.empty()) {
126 GetOStream(
Debug) <<
"resuming timer " << timerStack_.top()->name_ << std::endl;
127 timerStack_.top()->resume();
133 template <
class TagName>
144 template <
class TagName>
152 timer_->start(
false);
156 template <
class TagName>
158 if (timer_->isRunning()) {
162 return timer_->isRunning();
165 template <
class TagName>
171 template <
class TagName>
178 template <
class TagName>
181 template <
class TagName>
184 RCP<Teuchos::FancyOStream> fos = Teuchos::fancyOStream(Teuchos::rcpFromRef(std::cout)); fos->setOutputToRootOnly(0);
185 *fos <<
"Parent Child Map" << std::endl;
186 std::map<std::string, std::string >::const_iterator iter;
188 *fos <<
"Key: " << iter->first <<
" Value: " << iter->second << std::endl;
192 template <
class TagName>
194 : timer_(timer), isPaused_(false)
197 template <
class TagName>
199 TEUCHOS_TEST_FOR_EXCEPTION(timerStack_.empty(),
Exceptions::RuntimeError,
"MueLu::MutuallyExclusiveTime::TopOfTheStack(): timer is not the head of the stack (stack is empty).");
201 TEUCHOS_TEST_FOR_EXCEPTION(!(isRunning() || isPaused()),
Exceptions::RuntimeError,
"MueLu::MutuallyExclusiveTime::TopOfTheStack(): head of the stack timer is neither active nor paused.");
204 template <
class TagName>