40#ifndef TEUCHOS_TIMEMONITOR_HPP
41#define TEUCHOS_TIMEMONITOR_HPP
68#include "Teuchos_Comm.hpp"
77#define TEUCHOS_TIMER(funcName, strName) \
78 static Teuchos::Time& funcName() \
79 {static Teuchos::RCP<Time> rtn = \
80 Teuchos::TimeMonitor::getNewCounter(strName); return *rtn;}
91#define TEUCHOS_FUNC_TIME_MONITOR_DIFF( FUNCNAME, DIFF ) \
92 static Teuchos::RCP<Teuchos::Time> DIFF ## blabla_localTimer; \
93 if(!DIFF ## blabla_localTimer.get()) { \
94 std::ostringstream oss; \
96 DIFF ## blabla_localTimer = Teuchos::TimeMonitor::getNewCounter(oss.str()); \
98 Teuchos::TimeMonitor DIFF ## blabla_localTimeMonitor(*DIFF ## blabla_localTimer)
123#define TEUCHOS_FUNC_TIME_MONITOR( FUNCNAME ) \
124 TEUCHOS_FUNC_TIME_MONITOR_DIFF( FUNCNAME, main )
143typedef std::map<std::string, std::vector<std::pair<double, double> > >
stat_map_type;
211 return getNewCounter (name);
229 static void disableTimer (
const std::string& name);
239 static void enableTimer (
const std::string& name);
247 static void zeroOutTimers();
369 const std::string&
filter=
"");
410 const std::string&
filter=
"");
481 std::ostream &out=std::cout,
486 const std::string&
filter=
"",
507 summarize (std::ostream& out=std::cout,
512 const std::string&
filter=
"",
599 const std::string&
filter,
616 report (std::ostream& out,
617 const std::string&
filter,
625 report (std::ostream& out,
645 enum ETimeMonitorReportFormat {
654 enum ETimeMonitorYamlFormat {
674 summarizeToYaml (Ptr<
const Comm<int> > comm,
676 const ETimeMonitorYamlFormat yamlStyle,
677 const std::string& filter=
"");
684 summarizeToYaml (std::ostream& out,
685 const ETimeMonitorYamlFormat yamlStyle,
686 const std::string& filter=
"");
692 static void setReportFormatParameter (ParameterList& plist);
698 static void setYamlFormatParameter (ParameterList& plist);
704 static void setSetOpParameter (ParameterList& plist);
720 static void setReportParameters (
const RCP<ParameterList>& params);
728 static ETimeMonitorReportFormat reportFormat_;
733 static ETimeMonitorYamlFormat yamlStyle_;
741 static bool alwaysWriteLocal_;
748 static bool writeGlobalStats_;
751 static bool writeZeroTimers_;
758 static bool setParams_;
812class TimeMonitorSurrogateImpl :
public CommandLineProcessor::TimeMonitorSurrogate
814 virtual void summarize (std::ostream& out) {
860class TimeMonitorSurrogateImplInserter {
863 TimeMonitorSurrogateImplInserter () {
864 if (
is_null (CommandLineProcessor::getTimeMonitorSurrogate ())) {
865 CommandLineProcessor::setTimeMonitorSurrogate (
Teuchos::rcp (
new TimeMonitorSurrogateImpl));
876Teuchos::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() override
Destructor: stops the timer.
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.