Teuchos - Trilinos Tools Package Version of the Day
A scope-safe timer wrapper class. More...
|TimeMonitor (Time &timer, bool reset=false)|
|Constructor starts the timer. |
|Destructor causes timer to stop. |
|static Teuchos::RCP< Time >||getNewTimer (const std::string &name)|
|Return a new timer with the given name. |
|static void||zeroOutTimers ()|
|Reset all global timers to zero. |
|static void||summarize (std::ostream &out=std::cout, const bool alwaysWriteLocal=false, const bool writeGlobalStats=true, const bool writeZeroTimers=true, const ECounterSetOp setOp=Intersection)|
|Print summary statistics for all timers. |
A scope-safe timer wrapper class.
TimeMonitor objects start the timer when constructed, and stop the timer when the destructor is called. Termination upon destruction lets this timer behave correctly even if scope is exited because of an exception. TimeMonitor also keeps track of the set of all timers, and has a method (
summarize()) for printing out global statistics (min, mean, and max over all MPI processes, in an MPI build).
|static Teuchos::RCP<Time> Teuchos::TimeMonitor::getNewTimer||(||const std::string &||name||)||
|void Teuchos::TimeMonitor::summarize||(||std::ostream &||out =
|const bool||alwaysWriteLocal =
|const bool||writeGlobalStats =
|const bool||writeZeroTimers =
|const ECounterSetOp||setOp =
Print summary statistics for all timers.
The typical use case for timers is that all MPI processes create the same set of timers, and then want to report summary statistics. This method's default behavior (writeGlobalStats=true) is to report the mininum, arithmetic mean, and maximum for each timer. Duplicate timers get merged additively.
Note that different MPI processes may have different sets of timers. If writeGlobalStats is true, we have to reconcile the different sets of timers somehow. This method gives you two options: if setOp is Intersection, it computes the intersection (the common subset) of timers on all MPI processes, otherwise if setOp is Union, it computes the union of timers on all MPI processes. Intersection is the default, since it expresses a common case of timing global solvers.
Suppose there are MPI processes, unique timers in the global union, and unique timers in the global intersection. This method requires messages ( "reductions" and exactly 1 "broadcast") and per-processor storage (in the worst case) when computing either the intersection or the union of timers (the algorithm is similar in either case). The whole algorithm takes at worst time along the critical path (i.e., on the "slowest MPI process").
|out||[out] Output stream to which to write. This will only be used on MPI Rank 0.|
|alwaysWriteLocal||[in] If true, MPI Proc 0 will write its local timings to the given output stream. Defaults to false, since the global statistics are more meaningful. If the local set of timers differs from the global set of timers (either the union or the intersection, depending on |
|writeGlobalStats||[in] If true (the default), compute and display the min, average (arithmetic mean), and max of all timings over all processors (in MPI_COMM_WORLD). If there is only one MPI process or if this is a non-MPI build of Trilinos, we only show the "global" timings, without the "statistics" that would be all the same anyway.|
|writeZeroTimers||[in] If false, do not display results for timers that have never been called (numCalls() == 0). If true, display results for all timers.|
|setOp||[in] If Intersection, compute and display the intersection of all created timers over all processors. If Union, compute and display the union of all created timers over all processors.|