10#ifndef TEUCHOS_TIMEMONITOR_HPP
11#define TEUCHOS_TIMEMONITOR_HPP
38#include "Teuchos_Comm.hpp"
47#define TEUCHOS_TIMER(funcName, strName) \
48 static Teuchos::Time& funcName() \
49 {static Teuchos::RCP<Time> rtn = \
50 Teuchos::TimeMonitor::getNewCounter(strName); return *rtn;}
61#define TEUCHOS_FUNC_TIME_MONITOR_DIFF( FUNCNAME, DIFF ) \
62 static Teuchos::RCP<Teuchos::Time> DIFF ## blabla_localTimer; \
63 if(!DIFF ## blabla_localTimer.get()) { \
64 std::ostringstream oss; \
66 DIFF ## blabla_localTimer = Teuchos::TimeMonitor::getNewCounter(oss.str()); \
68 Teuchos::TimeMonitor DIFF ## blabla_localTimeMonitor(*DIFF ## blabla_localTimer)
93#define TEUCHOS_FUNC_TIME_MONITOR( FUNCNAME ) \
94 TEUCHOS_FUNC_TIME_MONITOR_DIFF( FUNCNAME, main )
113typedef std::map<std::string, std::vector<std::pair<double, double> > >
stat_map_type;
181 return getNewCounter (name);
199 static void disableTimer (
const std::string& name);
209 static void enableTimer (
const std::string& name);
217 static void zeroOutTimers();
339 const std::string&
filter=
"");
380 const std::string&
filter=
"");
451 std::ostream &out=std::cout,
456 const std::string&
filter=
"",
477 summarize (std::ostream& out=std::cout,
482 const std::string&
filter=
"",
569 const std::string&
filter,
586 report (std::ostream& out,
587 const std::string&
filter,
595 report (std::ostream& out,
610 static bool stackedTimerNameIsDefault();
617 enum ETimeMonitorReportFormat {
626 enum ETimeMonitorYamlFormat {
646 summarizeToYaml (Ptr<
const Comm<int> > comm,
648 const ETimeMonitorYamlFormat yamlStyle,
649 const std::string& filter=
"");
656 summarizeToYaml (std::ostream& out,
657 const ETimeMonitorYamlFormat yamlStyle,
658 const std::string& filter=
"");
664 static void setReportFormatParameter (ParameterList& plist);
670 static void setYamlFormatParameter (ParameterList& plist);
676 static void setSetOpParameter (ParameterList& plist);
692 static void setReportParameters (
const RCP<ParameterList>& params);
700 static ETimeMonitorReportFormat reportFormat_;
705 static ETimeMonitorYamlFormat yamlStyle_;
713 static bool alwaysWriteLocal_;
720 static bool writeGlobalStats_;
723 static bool writeZeroTimers_;
730 static bool setParams_;
784class TimeMonitorSurrogateImpl :
public CommandLineProcessor::TimeMonitorSurrogate
786 virtual void summarize (std::ostream& out) {
832class TimeMonitorSurrogateImplInserter {
835 TimeMonitorSurrogateImplInserter () {
836 if (
is_null (CommandLineProcessor::getTimeMonitorSurrogate ())) {
837 CommandLineProcessor::setTimeMonitorSurrogate (
Teuchos::rcp (
new TimeMonitorSurrogateImpl));
848Teuchos::TimeMonitorSurrogateImplInserter timeMonitorSurrogateImplInserter;
Basic command line parser for input from (argc,argv[])
Templated Parameter List class.
Basic wall-clock timer class.
Simple wrapper class for raw pointers to single objects where no persisting relationship exists.
Smart reference counting pointer class for automatic garbage collection.
A TimeMonitor that waits at a MPI barrier before destruction.
SyncTimeMonitor()=delete
Default constructor is deleted, since it would be unsafe.
Scope guard for Time, that can compute MPI collective timer statistics.
static void summarize(Ptr< const Comm< int > > comm, std::ostream &out=std::cout, const bool alwaysWriteLocal=false, const bool writeGlobalStats=true, const bool writeZeroTimers=true, const ECounterSetOp setOp=Intersection, const std::string &filter="", const bool ignoreZeroTimers=false)
Print summary statistics for all timers on the given communicator.
static Teuchos::RCP< Teuchos::StackedTimer > stackedTimer_
Stacked timer for optional injection of timing from TimeMonitor-enabled objects.
static RCP< Time > getNewTimer(const std::string &name)
Return a new timer with the given name (class method).
TimeMonitor()=delete
Default constructor is deleted, since it would be unsafe.
bool is_null(const std::shared_ptr< T > &p)
Returns true if p.get()==NULL.
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...
ECounterSetOp
Set operation type for mergeCounterNames() to perform.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.
std::map< std::string, std::vector< std::pair< double, double > > > stat_map_type
Global statistics collected from timer data.