13 level_(std::numeric_limits<unsigned>::max()),name_(
"INVALID"),parent_(nullptr)
24 for (
unsigned i=0; i<level_; ++i)
26 os << name_<<
":"<<
accumulatedTime()<<
" [" << count_started_<<
"] ("<< count_updates_ <<
")"<<std::endl;
28 for (
size_t i=0; i<sub_timers_.size(); ++i) {
29 t_total += sub_timers_[i].accumulatedTime();
30 sub_timers_[i].report(os);
32 if ( sub_timers_.size() == 0 )
34 for (
unsigned i=0; i<=level_; ++i)
43 if (get_full_name() == name) {
47 for (
unsigned i=0;i<sub_timers_.size(); ++i){
48 t = sub_timers_[i].findBaseTimer(name);
59 if (get_full_name() == name) {
64 for (
unsigned i=0;i<sub_timers_.size(); ++i){
65 t = sub_timers_[i].findTimer(name,found);
108 hist_[i].resize(num_names);
116 updates.
resize(num_names);
124 for (
int i=0;i<num_names; ++i) {
129 used[i] = t.count==0? 0:1;
131 updates[i] = t.updates;
145 for (
int i=0;i<num_names; ++i) {
151 int bin=(time[i]-
min_[i])/dh;
152 bins[i] = std::max(std::min(bin,options.
num_histogram-1) , 0);
157 for (
int i=0;i<num_names; ++i) {
168 for (
int i=0;i<num_names; ++i)
175 std::pair<std::string, std::string>
getPrefix(
const std::string &name) {
176 for (std::size_t i=name.size()-1; i>0; --i)
177 if (name[i] ==
'@') {
178 return std::pair<std::string, std::string>(name.substr(0,i), name.substr(i+1, name.size()));
180 return std::pair<std::string, std::string>(std::string(
""), name);
186 std::vector<bool> &printed,
192 double total_time = 0.0;
198 if ( (level != print_level) || (level >= options.
max_levels) )
201 if ( prefix != split_names.first)
206 std::ostringstream os;
207 for (
int l=0; l<level; ++l)
210 os << split_names.second <<
": ";
216 std::ostringstream os;
223 std::ostringstream os;
224 os <<
" - "<<
sum_[i]/
active_[i]/parent_time*100<<
"%";
230 std::ostringstream os;
237 std::ostringstream os;
245 std::ostringstream os;
246 os <<
" {min=" <<
min_[i];
250 std::ostringstream os;
251 os <<
", max=" <<
max_[i];
257 std::ostringstream os;
265 std::ostringstream os;
269 os <<
", "<<
hist_[h][i];
283 std::ostringstream tmp;
284 for (
int l=0; l<=level; ++l)
286 tmp <<
"Remainder: ";
290 std::ostringstream tmp;
295 std::ostringstream tmp;
314 double total_time = 0.0;
320 if ( (level != print_level) || (level >= options.
max_levels) )
323 if ( prefix != split_names.first)
328 std::ostringstream tmp;
329 for (
int l=0; l<level; ++l) {
333 tmp << split_names.second <<
": ";
340 std::ostringstream tmp;
348 std::ostringstream tmp;
349 tmp <<
" - "<<
sum_[i]/
active_[i]/parent_time*100<<
"%";
361 std::ostringstream tmp;
369 std::ostringstream tmp;
378 std::ostringstream tmp;
379 tmp <<
" {min="<<
min_[i];
385 std::ostringstream tmp;
386 tmp <<
", max="<<
max_[i];
394 std::ostringstream tmp;
405 for (
size_t j=0; j < offset; ++j)
411 std::ostringstream tmp;
415 tmp <<
", "<<
hist_[h][i];
431 std::ostringstream tmp;
433 for (
int l=0; l<level; ++l) {
437 tmp << split_names.second <<
": ";
448 std::ostringstream tmp;
449 for (
int l=0; l<=level; ++l)
451 tmp <<
"Remainder: ";
457 std::ostringstream tmp;
466 std::ostringstream tmp;
480 for (
size_t j=0; j < offset; ++j)
483 std::ostringstream tmp;
485 for (
int l=0; l<=level; ++l)
487 tmp <<
"Remainder: ";
504 if (rank(*comm) == 0 ) {
506 os <<
"*** Teuchos::StackedTimer::report() - Remainder for a level will be ***"
507 <<
"\n*** incorrect if a timer in the level does not exist on every rank ***"
508 <<
"\n*** of the MPI Communicator. ***"
512 os <<
"Teuchos::StackedTimer::report() - max_levels manually set to " << options.
max_levels
513 <<
". \nTo print more levels, increase value of OutputOptions::max_levels." << std::endl;
518 os <<
"Teuchos::StackedTimer::report() - option print_names_before_values=false "
519 <<
"\nrequires that the option align_columns=true too. Setting the value for "
520 <<
"\nalign_column to true."
std::string::size_type timer_names_
std::string::size_type histogram_
std::string::size_type average_time_
std::string::size_type total_updates_
void addTimerNames(Array< std::string > &names, unsigned &pos)
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.
void reduce< int, double >(const double sendBuf[], double recvBuf[], const int count, const EReductionType reductType, const int root, const Comm< int > &comm)
T * getRawPtr()
Return a raw pointer to beginning of array or NULL if unsized.
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)
double accumulatedTime(const std::string &name="")
std::string::size_type fraction_
std::string::size_type count_
void report(std::ostream &os)
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)
Array< Array< int > > hist_
void collectRemoteData(Teuchos::RCP< const Teuchos::Comm< int > > comm, const OutputOptions &options)
TEUCHOS_DEPRECATED void reduceAll(const Comm< Ordinal > &comm, const EReductionType reductType, const Packet &send, Packet *globalReduct)
Deprecated .
bool print_names_before_values
Array< unsigned long long > updates_
void mergeCounterNames(const Comm< int > &comm, const Array< std::string > &localNames, Array< std::string > &globalNames, const ECounterSetOp setOp)
Merge counter names over all processors.
std::string::size_type min_
void resize(size_type new_size, const value_type &x=value_type())
LevelTimer timer_
Base timer.
void error_out(const std::string &msg, const bool)
Error reporting function for stacked timer.
Abstract interface for distributed-memory communication.
Array< std::string > flat_names_
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
Smart reference counting pointer class for automatic garbage collection.
Array< unsigned long > count_
std::string::size_type stddev_
bool output_total_updates
Struct for controlling output options like histograms.
std::pair< std::string, std::string > getPrefix(const std::string &name)
struct Teuchos::StackedTimer::AlignmentWidths alignments_