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>
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>
112 template <
class TagName>
115 GetOStream(
Errors) <<
"MueLu::MutuallyExclusiveTime::stop(): timer is paused. Use resume()" << std::endl;
123 double r =
timer_->stop();
133 template <
class TagName>
144 template <
class TagName>
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>
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).");
204 template <
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.
static std::stack< MutuallyExclusiveTime< TagName > * > timerStack_
Stack of created timers (active or paused timers).
std::string name_
Name of this mutually exclusive timer.
MutuallyExclusiveTime(const std::string &name, bool startFlag=false)
Constructor.
void TopOfTheStack()
Check if 'this' is the head of the stack.
~MutuallyExclusiveTime()
Destructor.
double stop()
Stops the timer. The previous MutuallyExclusiveTime that has been paused when this timer was started ...
static void PrintParentChildPairs()
Print std::map of (child,parent) pairs for post-run analysis.
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.
RCP< Teuchos::Time > timer_
Using an RCP allows to use Teuchos::TimeMonitor to keep track of the timer.
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::map< std::string, std::string > myParent_