46 #ifndef MUELU_MUTUALLYEXCLUSIVETIME_HPP 47 #define MUELU_MUTUALLYEXCLUSIVETIME_HPP 54 #include "Teuchos_FancyOStream.hpp" 55 #include "Teuchos_RCP.hpp" 56 #include "Teuchos_RCPDecl.hpp" 57 #include "Teuchos_TestForException.hpp" 58 #include "Teuchos_Time.hpp" 59 #include "Teuchos_TimeMonitor.hpp" 68 extern std::map<std::string,std::string>
myParent_;
84 template<
class TagName>
94 timer_(rcp(
new Teuchos::Time(name,
false))),
98 if (startFlag ==
true)
timer_->start();
106 GetOStream(
Errors) <<
"MutuallyExclusiveTime::~MutuallyExclusiveTime(): Error: destructor called on a paused timer." << std::endl;
153 double r =
timer_->stop();
196 if (
timer_->isRunning()) {
200 return timer_->isRunning();
212 static RCP<MutuallyExclusiveTime<TagName> >
getNewTimer(
const std::string& name) {
232 RCP<Teuchos::FancyOStream> fos = Teuchos::fancyOStream(Teuchos::rcpFromRef(std::cout)); fos->setOutputToRootOnly(0);
233 *fos <<
"Parent Child Map" << std::endl;
234 std::map<std::string, std::string >::const_iterator iter;
236 *fos <<
"Key: " << iter->first <<
" Value: " << iter->second << std::endl;
263 TEUCHOS_TEST_FOR_EXCEPTION(
timerStack_.empty(),
Exceptions::RuntimeError,
"MueLu::MutuallyExclusiveTime::TopOfTheStack(): timer is not the head of the stack (stack is empty).");
276 #endif // MUELU_MUTUALLYEXCLUSIVETIME_HPP 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.
static void PrintParentChildPairs()
Print std::map of (child,parent) pairs for post-run analysis.
~MutuallyExclusiveTime()
Destructor.
Print additional debugging information.
Namespace for MueLu classes and methods.
void start(bool reset=false)
Starts the timer. If a MutuallyExclusiveTime timer is running, it will be stopped.
std::map< std::string, std::string > myParent_
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.
static RCP< MutuallyExclusiveTime< TagName > > getNewTimer(const std::string &name)
Return a new MutuallyExclusiveTime that is registered with the Teuchos::TimeMonitor (for timer summar...
void pause()
Pause running timer. Used internally by start().
Base class for MueLu classes.
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.
MutuallyExclusiveTime(RCP< Teuchos::Time > timer)