MueLu  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MueLu_Monitor.cpp
Go to the documentation of this file.
1 #include "MueLu_Monitor.hpp"
3 
4 namespace MueLu {
5 PrintMonitor::PrintMonitor(const BaseClass& object, const std::string& msg, MsgType msgLevel)
6  : object_(object) {
7  tabbed = false;
8  if (object_.IsPrint(msgLevel)) {
9  // Print description and new indent
10  object_.GetOStream(msgLevel, 0) << msg << std::endl;
11  object_.getOStream()->pushTab();
12  tabbed = true;
13  }
14 }
15 
17  if (tabbed) object_.getOStream()->popTab();
18 }
19 
20 Monitor::Monitor(const BaseClass& object, const std::string& msg, MsgType msgLevel, MsgType timerLevel)
21  : printMonitor_(object, msg + " (" + object.description() + ")", msgLevel)
22  , timerMonitor_(object, object.ShortClassName() + ": " + msg + " (total)", timerLevel) {}
23 
24 Monitor::Monitor(const BaseClass& object, const std::string& msg, const std::string& label, MsgType msgLevel, MsgType timerLevel)
25  : printMonitor_(object, label + msg + " (" + object.description() + ")", msgLevel)
26  , timerMonitor_(object, label + object.ShortClassName() + ": " + msg + " (total)", timerLevel) {}
27 
28 SubMonitor::SubMonitor(const BaseClass& object, const std::string& msg, MsgType msgLevel, MsgType timerLevel)
29  : printMonitor_(object, msg, msgLevel)
30  , timerMonitor_(object, object.ShortClassName() + ": " + msg + " (sub, total)", timerLevel) {}
31 
32 SubMonitor::SubMonitor(const BaseClass& object, const std::string& msg, const std::string& label, MsgType msgLevel, MsgType timerLevel)
33  : printMonitor_(object, label + msg, msgLevel)
34  , timerMonitor_(object, label + object.ShortClassName() + ": " + msg + " (sub, total)", timerLevel) {}
35 
36 FactoryMonitor::FactoryMonitor(const BaseClass& object, const std::string& msg, int levelID, MsgType msgLevel, MsgType timerLevel)
37  : Monitor(object, msg, msgLevel, timerLevel)
38  , timerMonitorExclusive_(object, object.ShortClassName() + ": " + msg, timerLevel) {
39  if (object.IsPrint(TimingsByLevel)) {
41  levelTimeMonitor_ = rcp(new TimeMonitor(object, object.ShortClassName() + ": " + msg + " (total, level=" + Teuchos::Utils::toString(levelID) + ")", timerLevel));
42  levelTimeMonitorExclusive_ = rcp(new MutuallyExclusiveTimeMonitor<Level>(object, object.ShortClassName() + ": " + msg + " (level=" + Teuchos::Utils::toString(levelID) + ")", timerLevel));
43  }
44 }
45 
46 FactoryMonitor::FactoryMonitor(const BaseClass& object, const std::string& msg, const Level& level, MsgType msgLevel, MsgType timerLevel)
47  : Monitor(object, msg, FormattingHelper::getColonLabel(level.getObjectLabel()), msgLevel, timerLevel)
48  , timerMonitorExclusive_(object, FormattingHelper::getColonLabel(level.getObjectLabel()) + object.ShortClassName() + ": " + msg, timerLevel) {
49  if (object.IsPrint(TimingsByLevel)) {
50  std::string label = FormattingHelper::getColonLabel(level.getObjectLabel());
52  levelTimeMonitor_ = rcp(new TimeMonitor(object, label + object.ShortClassName() + ": " + msg + " (total, level=" + Teuchos::Utils::toString(level.GetLevelID()) + ")", timerLevel));
53  levelTimeMonitorExclusive_ = rcp(new MutuallyExclusiveTimeMonitor<Level>(object, label + object.ShortClassName() + ": " + msg + " (level=" + Teuchos::Utils::toString(level.GetLevelID()) + ")", timerLevel));
54  }
55 }
56 
57 SubFactoryMonitor::SubFactoryMonitor(const BaseClass& object, const std::string& msg, int levelID, MsgType msgLevel, MsgType timerLevel)
58  : SubMonitor(object, msg, msgLevel, timerLevel) {
60  levelTimeMonitor_ = rcp(new TimeMonitor(object, object.ShortClassName() + ": " + msg + " (sub, total, level=" + Teuchos::Utils::toString(levelID) + ")", timerLevel));
61 }
62 
63 SubFactoryMonitor::SubFactoryMonitor(const BaseClass& object, const std::string& msg, const Level& level, MsgType msgLevel, MsgType timerLevel)
64  : SubMonitor(object, msg, FormattingHelper::getColonLabel(level.getObjectLabel()), msgLevel, timerLevel) {
66  std::string label = FormattingHelper::getColonLabel(level.getObjectLabel());
67  levelTimeMonitor_ = rcp(new TimeMonitor(object, label + object.ShortClassName() + ": " + msg + " (sub, total, level=" + Teuchos::Utils::toString(level.GetLevelID()) + ")", timerLevel));
68  }
69 }
70 
71 } // namespace MueLu
static Teuchos::RCP< Teuchos::StackedTimer > getStackedTimer()
RCP< TimeMonitor > levelTimeMonitor_
Total time spent on this level in this object and all children.
Teuchos::FancyOStream & GetOStream(MsgType type, int thisProcRankOnly=0) const
Get an output stream for outputting the input message type.
virtual std::string getObjectLabel() const
bool is_null(const boost::shared_ptr< T > &p)
Timer to be used in non-factories. Similar to Monitor, but doesn&#39;t print object description.
Integrates Teuchos::TimeMonitor with MueLu verbosity system.
static std::string toString(const double &x)
virtual std::string ShortClassName() const
Return the class name of the object, without template parameters and without namespace.
static std::string getColonLabel(const std::string &label)
Helper function for object label.
Monitor(const BaseClass &object, const std::string &msg, MsgType msgLevel=Runtime0, MsgType timerLevel=Timings0)
Constructor.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Class that holds all level-specific information.
Definition: MueLu_Level.hpp:99
RCP< TimeMonitor > levelTimeMonitor_
Total time spent on this level in this object and all its children.
FactoryMonitor(const BaseClass &object, const std::string &msg, int levelID, MsgType msgLevel=static_cast< MsgType >(Test|Runtime0), MsgType timerLevel=Timings0)
Constructor.
bool IsPrint(MsgType type, int thisProcRankOnly=-1) const
Find out whether we need to print out information for a specific message type.
Similar to TimeMonitor, but uses MutuallyExclusiveTime objects.
Base class for MueLu classes.
Record timing information level by level. Must be used in combinaison with Timings0/Timings1.
SubFactoryMonitor(const BaseClass &object, const std::string &msg, int levelID, MsgType msgLevel=Runtime1, MsgType timerLevel=Timings1)
Constructor.
Timer to be used in non-factories.
RCP< MutuallyExclusiveTimeMonitor< Level > > levelTimeMonitorExclusive_
Total time spent on this level in this object only, excluding all children.
int GetLevelID() const
Return level number.
Definition: MueLu_Level.cpp:76
const BaseClass & object_
virtual RCP< FancyOStream > getOStream() const
SubMonitor(const BaseClass &object, const std::string &msg, MsgType msgLevel=Runtime1, MsgType timerLevel=Timings1)
Constructor.