63 for (
unsigned i=0;
i<level_; ++
i)
65 os << name_<<
":"<<
accumulatedTime()<<
" [" << count_started_<<
"] ("<< count_updates_ <<
")"<<std::endl;
67 for (
size_t i=0;
i<sub_timers_.
size(); ++
i) {
68 t_total += sub_timers_[
i].accumulatedTime();
69 sub_timers_[
i].report(
os);
71 if ( sub_timers_.size() == 0 )
73 for (
unsigned i=0;
i<=level_; ++
i)
82 if (get_full_name() == name) {
86 for (
unsigned i=0;
i<sub_timers_.
size(); ++
i){
87 t = sub_timers_[
i].findBaseTimer(name);
103 if (get_full_name() == name) {
108 for (
unsigned i=0;
i<sub_timers_.
size(); ++
i){
109 t = sub_timers_[
i].findTimer(name,
found);
154 if (
options.output_proc_minmax) {
160 if (
options.output_histogram ) {
170 if (
options.output_total_updates)
184 used[
i] = t.count==0? 0:1;
185 if (
options.output_total_updates)
186 updates[
i] = t.updates;
222 if (
options.output_histogram) {
254std::pair<std::string, std::string>
getPrefix(
const std::string &name) {
255 for (std::size_t
i=name.
size()-1;
i>0; --
i)
256 if (name[
i] ==
'@') {
257 return std::pair<std::string, std::string>(name.substr(0,
i), name.substr(
i+1));
259 return std::pair<std::string, std::string>(std::string(
""), name);
287 std::ostringstream
os;
288 for (
int l=0;
l<level; ++
l)
297 std::ostringstream
os;
304 std::ostringstream
os;
311 std::ostringstream
os;
317 if (
options.output_total_updates) {
318 std::ostringstream
os;
326 std::ostringstream
os;
331 std::ostringstream
os;
338 std::ostringstream
os;
345 std::ostringstream
os;
352 std::ostringstream
os;
360 std::ostringstream
os;
377 if (
options.print_names_before_values) {
378 std::ostringstream
tmp;
379 for (
int l=0;
l<=level; ++
l)
381 tmp <<
"Remainder: ";
385 std::ostringstream
tmp;
390 std::ostringstream
tmp;
425 if (
options.print_names_before_values) {
426 std::ostringstream
tmp;
427 for (
int l=0;
l<level; ++
l) {
438 std::ostringstream
tmp;
446 std::ostringstream
tmp;
453 else if (
options.output_fraction) {
459 std::ostringstream
tmp;
466 if (
options.output_total_updates ) {
467 std::ostringstream
tmp;
476 std::ostringstream
tmp;
483 std::ostringstream
tmp;
492 std::ostringstream
tmp;
501 std::ostringstream
tmp;
510 std::ostringstream
tmp;
518 else if (
options.output_minmax) {
527 std::ostringstream
tmp;
540 else if (
options.output_histogram) {
546 if (!
options.print_names_before_values) {
547 std::ostringstream
tmp;
549 for (
int l=0;
l<level; ++
l) {
563 if (
options.print_names_before_values) {
564 std::ostringstream
tmp;
565 for (
int l=0;
l<=level; ++
l)
567 tmp <<
"Remainder: ";
573 std::ostringstream
tmp;
582 std::ostringstream
tmp;
586 if (!
options.print_names_before_values) {
590 if (
options.output_total_updates)
599 std::ostringstream
tmp;
601 for (
int l=0;
l<=level; ++
l)
603 tmp <<
"Remainder: ";
668 for (
int j = 0;
j < indent;
j++)
670 os <<
"<timing name=\"";
693 for (
int j = 0;
j < indent;
j++)
712 if (rank(*
comm) == 0 ) {
714 os <<
"*** Teuchos::StackedTimer::report() - Remainder for a level will be ***"
715 <<
"\n*** incorrect if a timer in the level does not exist on every rank ***"
716 <<
"\n*** of the MPI Communicator. ***"
720 os <<
"Teuchos::StackedTimer::report() - max_levels manually set to " <<
options.max_levels
721 <<
". \nTo print more levels, increase value of OutputOptions::max_levels." << std::endl;
723 if ( (!
options.print_names_before_values) && (!
options.align_columns)) {
726 os <<
"Teuchos::StackedTimer::report() - option print_names_before_values=false "
727 <<
"\nrequires that the option align_columns=true too. Setting the value for "
728 <<
"\nalign_column to true."
748 if (rank(*
comm) == 0 ) {
750 os <<
"<?xml version=\"1.0\"?>\n";
751 os <<
"<performance-report date=\"" <<
timestamp <<
"\" name=\"nightly_run_" <<
datestamp <<
"\" time-units=\"seconds\">\n";
753 os <<
"</performance-report>\n";
789 throw std::invalid_argument(
"$WATCHR_BUILD_DATE has invalid year or is not in YYYY_MM_DD format.");
791 throw std::invalid_argument(
"$WATCHR_BUILD_DATE has invalid month or is not in YYYY_MM_DD format.");
793 throw std::invalid_argument(
"$WATCHR_BUILD_DATE has invalid day or is not in YYYY_MM_DD format.");
815 if(rank(*
comm) == 0) {
837 os <<
"<?xml version=\"1.0\"?>\n";
838 os <<
"<performance-report date=\"" <<
timestamp <<
"\" name=\"nightly_run_" <<
datestamp <<
"\" time-units=\"seconds\">\n";
845 os <<
" <metadata key=\"Trilinos Version\" value=\"" <<
gitSHA <<
"\"/>\n";
848 os <<
"</performance-report>\n";
T * getRawPtr()
Return a raw pointer to beginning of array or NULL if unsized.
void resize(size_type new_size, const value_type &x=value_type())
the basic timer used elsewhere, uses MPI_Wtime for time
int size(const Comm< Ordinal > &comm)
Get the number of processes in the communicator.
Smart reference counting pointer class for automatic garbage collection.
Concrete serial communicator subclass.
virtual int getRank() const
void report(std::ostream &os)
void addTimerNames(Array< std::string > &names, unsigned &pos)
BaseTimer::TimeInfo findTimer(const std::string &name, bool &found)
const BaseTimer * findBaseTimer(const std::string &name) const
LevelTimer()
Default constructor, shouldn't be used but needed for std::vector.
struct Teuchos::StackedTimer::AlignmentWidths alignments_
double computeColumnWidthsForAligment(std::string prefix, int print_level, std::vector< bool > &printed, double parent_time, const OutputOptions &options)
void collectRemoteData(Teuchos::RCP< const Teuchos::Comm< int > > comm, const OutputOptions &options)
Array< Array< int > > hist_
Teuchos::RCP< std::ostream > verbose_ostream_
For debugging, this is the ostream used for printing.
double printLevelXML(std::string prefix, int level, std::ostream &os, std::vector< bool > &printed, double parent_time, const std::string &rootName="")
Array< unsigned long long > updates_
void report(std::ostream &os)
void enableVerboseTimestamps(const unsigned levels)
Enable timestamps in verbose mode for the number of levels specified.
Array< std::string > flat_names_
void setVerboseOstream(const Teuchos::RCP< std::ostream > &os)
Set the ostream for verbose mode(defaults to std::cout).
bool enable_timers_
Used to disable timers for asynchronous work.
Array< unsigned long > count_
unsigned verbose_timestamp_levels_
If set to a value greater than 0, verbose mode will print that many levels of timers with timestamps....
double accumulatedTime(const std::string &name="")
LevelTimer timer_
Base timer.
bool enable_verbose_
If set to true, prints to the debug ostream. At construction, default value is set from environment v...
void merge(Teuchos::RCP< const Teuchos::Comm< int > > comm)
double printLevel(std::string prefix, int level, std::ostream &os, std::vector< bool > &printed, double parent_time, const OutputOptions &options)
void enableVerbose(const bool enable_verbose)
If set to true, print timer start/stop to verbose ostream.
std::string reportWatchrXML(const std::string &name, Teuchos::RCP< const Teuchos::Comm< int > > comm)
void reportXML(std::ostream &os, const std::string &datestamp, const std::string ×tamp, Teuchos::RCP< const Teuchos::Comm< int > > comm)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
static void printXMLEscapedString(std::ostream &os, const std::string &str)
std::pair< std::string, std::string > getPrefix(const std::string &name)
void mergeCounterNames(const Comm< int > &comm, const Array< std::string > &localNames, Array< std::string > &globalNames, const ECounterSetOp setOp)
Merge counter names over all processors.
void reduce< int, double >(const double sendBuf[], double recvBuf[], const int count, const EReductionType reductType, const int root, const Comm< int > &comm)
void error_out(const std::string &msg, const bool)
Error reporting function for stacked timer.