4 #ifndef TEUCHOS_STACKED_TIMER_HPP 
    5 #define TEUCHOS_STACKED_TIMER_HPP 
   20 #if defined(HAVE_TEUCHOS_KOKKOS_PROFILING) && defined(HAVE_TEUCHOSCORE_KOKKOSCORE) 
   23 extern void pushRegion (
const std::string&);
 
   24 extern void popRegion ();
 
   33 void error_out(
const std::string& msg, 
const bool fail_all = 
false);
 
   48   using Clock = std::chrono::high_resolution_clock;
 
   55       error_out(
"Base_Timer:start Failed timer already running");
 
   65       error_out(
"Base_Timer:stop Failed timer not running");
 
  124        error_out(
"BaseTimer, cannot reset a running timer");
 
  215         const char* name = 
"RootTimer",
 
  217         bool start_timer=
true) :
 
  260         error_out(
"Stopping timer "+name+
" But top level running timer is "+
name_);
 
  271       std::string parent_name(
"");
 
  275       std::string my_name(
name_);
 
  277       std::string full_name = parent_name + my_name;
 
  306       if (locate_name == 
"")
 
  309       std::string first_name,second_name;
 
  311       size_t i = locate_name.find_first_of(
'@');
 
  312       if ( i >= locate_name.size() ) {
 
  313         first_name = locate_name;
 
  316         first_name.assign(locate_name,0,i);
 
  317         second_name.assign(locate_name,i+1,locate_name.size()-i-1);
 
  321           return sub_timers_[j].accumulatedTime(second_name);
 
  332     void splitString(
const std::string &locate_name, std::string &first_name, std::string &second_name) {
 
  333       size_t i = locate_name.find_first_of(
'@');
 
  334       if ( i >= locate_name.size() ) {
 
  335         first_name = locate_name;
 
  338         first_name.assign(locate_name,0,i);
 
  339         second_name.assign(locate_name,i+1,locate_name.size()-i-1);
 
  351        if (locate_name == 
"")
 
  354        std::string first_name,second_name;
 
  359            return sub_timers_[j].accumulatedTimePerUpdate(second_name);
 
  370        if (locate_name == 
"")
 
  373        std::string first_name,second_name;
 
  378            return sub_timers_[j].accumulatedTimePerTimerCall(second_name);
 
  398      void report(std::ostream &os);
 
  429   explicit StackedTimer(
const char *name, 
const bool start_base_timer = 
true)
 
  430     : 
timer_(0,name,nullptr,false)
 
  433     if (start_base_timer)
 
  441     timer_.BaseTimer::start();
 
  442 #if defined(HAVE_TEUCHOS_KOKKOS_PROFILING) && defined(HAVE_TEUCHOSCORE_KOKKOSCORE) 
  452 #if defined(HAVE_TEUCHOS_KOKKOS_PROFILING) && defined(HAVE_TEUCHOSCORE_KOKKOSCORE) 
  453     ::Kokkos::Profiling::popRegion();
 
  463              const bool push_kokkos_profiling_region = 
true) {
 
  468 #if defined(HAVE_TEUCHOS_KOKKOS_PROFILING) && defined(HAVE_TEUCHOSCORE_KOKKOSCORE) 
  469     if (push_kokkos_profiling_region) {
 
  470       ::Kokkos::Profiling::pushRegion(name);
 
  480   void stop(
const std::string &name,
 
  481             const bool pop_kokkos_profiling_region = 
true) {
 
  486 #if defined(HAVE_TEUCHOS_KOKKOS_PROFILING) && defined(HAVE_TEUCHOSCORE_KOKKOSCORE) 
  487     if (pop_kokkos_profiling_region) {
 
  488       ::Kokkos::Profiling::popRegion();
 
  544                                "StackedTimer::findBaseTimer() failed to find a timer named \"" << name << 
"\"!\n");
 
  554     bool foundTimer = 
false;
 
  557       "StackedTimer::findTimer() failed to find a timer named \"" << name << 
"\"!\n");
 
  651                                         std::vector<bool> &printed, 
double parent_time,
 
  652                                         const OutputOptions &options);
 
  657   double printLevel(std::string prefix, 
int level, std::ostream &os, std::vector<bool> &printed,
 
  658                     double parent_time, 
const OutputOptions &options);
 
void setAccumulatedTime(double accum=0)
Setter for accumulated time. 
 
double accumulatedTimePerTimerCall(const std::string &name="")
 
Clock::time_point start_time_
 
double difference(const BaseTimer &from) const 
Return the difference between two timers in seconds,. 
 
StackedTimer(const char *name, const bool start_base_timer=true)
 
void overrideNumUpdatesForUnitTesting(const unsigned long long num_updates)
Sets the number of counts for this timer. This is only used for unit testing. 
 
std::string::size_type timer_names_
 
double accumulatedTime() const 
Get the total accumulated time since last reset or construction when the timer is running...
 
void splitString(const std::string &locate_name, std::string &first_name, std::string &second_name)
split a string into two parts split by a '@' if no '@' first gets the full string ...
 
void stop(const std::string &name, const bool pop_kokkos_profiling_region=true)
 
LevelTimer(int level, const char *name="RootTimer", LevelTimer *parent=nullptr, bool start_timer=true)
 
unsigned long long incrementUpdates(unsigned long long count=1)
Increment the total number of items updated between a start stop. 
 
std::string::size_type histogram_
 
std::string::size_type average_time_
 
bool running() const 
Returns true if the timer is currently accumulating time. 
 
std::string::size_type total_updates_
 
double accumulatedTimePerTimerCall() const 
return the average time per timer start/stop 
 
std::vector< LevelTimer > sub_timers_
 
void addTimerNames(Array< std::string > &names, unsigned &pos)
 
unsigned long count_started_
 
void merge(Teuchos::RCP< const Teuchos::Comm< int > > comm)
 
std::string::size_type max_
 
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging. 
 
double accumulatedTimePerUpdate() const 
return the average time per item updated 
 
Teuchos header file which uses auto-configuration information to include necessary C++ headers...
 
void incrementUpdates(const long long i=1)
 
void start()
Start a currently stopped timer. 
 
LevelTimer * top_
Current level running. 
 
double accumulatedTimePerUpdate(const std::string &name="")
 
unsigned long numCalls() const 
Returns the number of calls to start(). 
 
BaseTimer::TimeInfo findTimer(const std::string &name, bool &found)
 
double printLevel(std::string prefix, int level, std::ostream &os, std::vector< bool > &printed, double parent_time, const OutputOptions &options)
 
LevelTimer * unpack(unsigned from)
 
double accumulatedTime(const std::string &name="")
 
std::string::size_type fraction_
 
std::string::size_type count_
 
void start(const std::string name, const bool push_kokkos_profiling_region=true)
 
double accumulatedTime(const std::string &locate_name="")
 
void report(std::ostream &os)
 
void overrideNumCallsForUnitTesting(const unsigned long num_calls)
Sets the number of calls to start() for this timer. This is only used for unit testing. 
 
the basic timer used elsewhere, uses MPI_Wtime for time 
 
double computeColumnWidthsForAligment(std::string prefix, int print_level, std::vector< bool > &printed, double parent_time, const OutputOptions &options)
 
Stores the column widths for output alignment. 
 
Array< Array< int > > hist_
 
void collectRemoteData(Teuchos::RCP< const Teuchos::Comm< int > > comm, const OutputOptions &options)
 
std::chrono::high_resolution_clock Clock
 
LevelTimer(const LevelTimer &src)
Copy constructor. 
 
bool print_names_before_values
 
Array< unsigned long long > updates_
 
Timer info at a given level and all the children. 
 
std::string::size_type min_
 
const BaseTimer * findBaseTimer(const std::string &name) const 
 
double accumulatedTimePerUpdate(const std::string &locate_name="")
 
LevelTimer timer_
Base timer. 
 
double accumulatedTimePerTimerCall(const std::string &locate_name="")
 
Templated array class derived from the STL std::vector. 
 
void error_out(const std::string &msg, const bool)
Error reporting function for stacked timer. 
 
Abstract interface for distributed-memory communication. 
 
LevelTimer * stop(const std::string &name="RootTimer")
 
void reset()
Reset all the timer stats, throws if it is already running. 
 
Array< std::string > flat_names_
 
void stop()
Stop a current running timer and accumulate time difference. 
 
void report(std::ostream &os)
 
LevelTimer()
Default constructor, shouldn't be used but needed for std::vector. 
 
const BaseTimer * findBaseTimer(const std::string &name) const 
 
unsigned long long count_updates_
 
Smart reference counting pointer class for automatic garbage collection. 
 
BaseTimer::TimeInfo findTimer(const std::string &name)
 
This class allows one to push and pop timers on and off a stack. 
 
unsigned long long numUpdates() const 
Returns the number of updates added to this timer. 
 
Array< unsigned long > count_
 
std::string::size_type stddev_
 
unsigned long long updates
 
bool output_total_updates
 
Struct for controlling output options like histograms. 
 
Reference-counted pointer class and non-member templated function implementations. 
 
LevelTimer * start(const char *sub_name)
 
std::string get_full_name() const 
 
struct Teuchos::StackedTimer::AlignmentWidths alignments_