Go to the documentation of this file.
20 #ifndef LIBMESH_PERFLOG_H
21 #define LIBMESH_PERFLOG_H
25 #include "libmesh/libmesh_common.h"
177 const char * header=
"");
188 void push (
const char * label,
189 const char * header=
"");
198 void push (
const std::string & label,
199 const std::string & header=
"");
208 const char * header=
"");
216 void pop (
const char * label,
217 const char * header=
"");
226 void pop (
const std::string & label,
227 const std::string & header=
"");
233 const std::string & header=
"");
239 const std::string & header=
"");
245 const std::string & header=
"");
251 const std::string & header=
"");
293 typedef std::map<std::pair<
const char *,
304 #ifdef LIBMESH_ENABLE_DEPRECATED
307 libmesh_deprecated();
361 std::vector<std::string> & output)
const;
383 gettimeofday (&(this->
tstart),
nullptr);
392 gettimeofday (&(this->
tstart),
nullptr);
410 tstart_tv_sec = this->
tstart.tv_sec,
411 tstart_tv_usec = this->
tstart.tv_usec;
413 gettimeofday (&(this->
tstart),
nullptr);
415 const double elapsed_time = (static_cast<double>(this->
tstart.tv_sec - tstart_tv_sec) +
416 static_cast<double>(this->
tstart.tv_usec - tstart_tv_usec)*1.e-6);
422 const double elapsed_time_incl_sub = (static_cast<double>(this->
tstart.tv_sec - this->tstart_incl_sub.tv_sec) +
423 static_cast<double>(this->
tstart.tv_usec - this->tstart_incl_sub.tv_usec)*1.e-6);
436 gettimeofday (&(other.
tstart),
nullptr);
438 const double elapsed_time = (static_cast<double>(other.
tstart.tv_sec - this->tstart.tv_sec) +
439 static_cast<double>(other.
tstart.tv_usec - this->tstart.tv_usec)*1.e-6);
473 PerfData * perf_data = &(
log[std::make_pair(header,label)]);
487 const char * libmesh_dbg_var(header))
494 PerfData * perf_data = &(
log[std::make_pair(header,label)]);
497 libMesh::err <<
"PerfLog can't pop (" << header <<
',' << label <<
')' << std::endl;
498 libMesh::err <<
"From top of stack of running logs:" << std::endl;
501 libMesh::err <<
'(' << i.first.first <<
',' << i.first.second <<
')' << std::endl;
503 libmesh_assert_equal_to (perf_data,
log_stack.top());
523 gettimeofday (&tnow,
nullptr);
525 const double elapsed_time = (static_cast<double>(tnow.tv_sec -
tstart.tv_sec) +
526 static_cast<double>(tnow.tv_usec -
tstart.tv_usec)*1.e-6);
540 #endif // LIBMESH_PERFLOG_H
void split_on_whitespace(const std::string &input, std::vector< std::string > &output) const
Splits a string on whitespace into a vector of separate strings.
The PerfData class simply contains the performance data that is recorded for individual events.
void fast_push(const char *label, const char *header="")
Push the event label onto the stack, pausing any active event.
bool open
Flag indicating if we are currently monitoring this event.
void enable_logging()
Enables performance logging for an active object.
void clear()
Clears all the internal data and restores the data structures to a pristine state.
void print_log() const
Print the log.
The libMesh namespace provides an interface to certain functionality in the library.
double stop_or_pause(const bool do_stop)
PerfData get_perf_data(const std::string &label, const std::string &header="")
Return the PerfData object associated with a label and header.
std::map< std::pair< const char *, const char * >, PerfData > log_type
Typdef for the underlying logging data structure.
bool logging_enabled() const
std::string get_log() const
const log_type & get_log_raw() const
void stop_event(const std::string &label, const std::string &header="")
Stop monitoring the event named label.
bool log_events
Flag to optionally disable all logging.
std::string get_info_header() const
double pause_for(PerfData &other)
log_type log
The actual log.
void pop(const char *label, const char *header="")
Pop the event label off the stack, resuming any lower event.
PerfLog(const std::string &label_name="", const bool log_events=true)
Constructor.
void pause_event(const std::string &label, const std::string &header="")
Suspend monitoring of the event.
void fast_pop(const char *label, const char *header="")
Pop the event label off the stack, resuming any lower event.
struct timeval tstart
Structure defining when the event was last started.
The PerfLog class allows monitoring of specific events.
struct timeval tstart
The time we were constructed or last cleared.
void disable_logging()
Disables performance logging for an active object.
double get_active_time() const
std::stack< PerfData * > log_stack
A stack to hold the current performance log trace.
std::string get_perf_info() const
double tot_time
Total time spent in this event.
unsigned int count
The number of times this event has been executed.
static bool called
Flag indicating if print_log() has been called.
struct timeval tstart_incl_sub
Structure defining when the event was last started, including sub-events.
double get_elapsed_time() const
void push(const char *label, const char *header="")
Push the event label onto the stack, pausing any active event.
const std::string label_name
The label for this object.
void restart_event(const std::string &label, const std::string &header="")
Restart monitoring the event.
double total_time
The total running time for recorded events.
double tot_time_incl_sub
Total time spent in this event, including sub-events.
void start_event(const std::string &label, const std::string &header="")
Start monitoring the event named label.
std::map< std::string, const char * > non_temporary_strings
Workaround to give us fixed pointers to character arrays for every string.