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>
104 myParent_[this->
name_] =
"no parent";
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>
void TopOfTheStack()
Check if 'this' is the head of the stack.
static std::stack< MutuallyExclusiveTime< TagName > * > timerStack_
Stack of created timers (active or paused timers).
Teuchos::FancyOStream & GetOStream(MsgType type, int thisProcRankOnly=0) const
Get an output stream for outputting the input message type.
std::map< std::string, std::string > myParent_
~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...
Namespace for MueLu classes and methods.
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.
double stop()
Stops the timer. The previous MutuallyExclusiveTime that has been paused when this timer was started ...
std::string name_
Name of this mutually exclusive timer.
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.
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.