libMesh::PerfData Class Reference

Data object managed by PerfLog. More...

#include <perf_log.h>

Public Member Functions

 PerfData ()
 
void start ()
 
void restart ()
 
double pause ()
 
double pause_for (PerfData &other)
 
double stopit ()
 

Public Attributes

double tot_time
 
double tot_time_incl_sub
 
struct timeval tstart
 
struct timeval tstart_incl_sub
 
unsigned int count
 
bool open
 
int called_recursively
 

Protected Member Functions

double stop_or_pause (const bool do_stop)
 

Detailed Description

Data object managed by PerfLog.

The PerfData class simply contains the performance data that is recorded for individual events.

Author
Benjamin Kirk
Date
2003

Definition at line 46 of file perf_log.h.

Constructor & Destructor Documentation

◆ PerfData()

libMesh::PerfData::PerfData ( )
inline

Constructor. Initializes data to be empty.

Definition at line 53 of file perf_log.h.

53  :
54  tot_time(0.),
56  tstart(),
58  count(0),
59  open(false),
61  {}
double tot_time_incl_sub
Definition: perf_log.h:72
int called_recursively
Definition: perf_log.h:105
struct timeval tstart
Definition: perf_log.h:78
struct timeval tstart_incl_sub
Definition: perf_log.h:84
double tot_time
Definition: perf_log.h:67
unsigned int count
Definition: perf_log.h:90

Member Function Documentation

◆ pause()

double libMesh::PerfData::pause ( )
inline

Definition at line 398 of file perf_log.h.

References stop_or_pause().

399 {
400  return this->stop_or_pause(false);
401 }
double stop_or_pause(const bool do_stop)
Definition: perf_log.h:405

◆ pause_for()

double libMesh::PerfData::pause_for ( PerfData other)
inline

Definition at line 434 of file perf_log.h.

References called_recursively, count, tot_time, tstart, and tstart_incl_sub.

435 {
436  gettimeofday (&(other.tstart), nullptr);
437 
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);
440  this->tot_time += elapsed_time;
441 
442  other.count++;
443  other.called_recursively++;
444  other.tstart_incl_sub = other.tstart;
445 
446  return elapsed_time;
447 }
struct timeval tstart
Definition: perf_log.h:78
double tot_time
Definition: perf_log.h:67

◆ restart()

void libMesh::PerfData::restart ( )
inline

Definition at line 390 of file perf_log.h.

References tstart.

391 {
392  gettimeofday (&(this->tstart), nullptr);
393 }
struct timeval tstart
Definition: perf_log.h:78

◆ start()

void libMesh::PerfData::start ( )
inline

Definition at line 379 of file perf_log.h.

References called_recursively, count, tstart, and tstart_incl_sub.

Referenced by libMesh::PerfLog::fast_push().

380 {
381  this->count++;
382  this->called_recursively++;
383  gettimeofday (&(this->tstart), nullptr);
384  this->tstart_incl_sub = this->tstart;
385 }
int called_recursively
Definition: perf_log.h:105
struct timeval tstart
Definition: perf_log.h:78
struct timeval tstart_incl_sub
Definition: perf_log.h:84
unsigned int count
Definition: perf_log.h:90

◆ stop_or_pause()

double libMesh::PerfData::stop_or_pause ( const bool  do_stop)
inlineprotected

Definition at line 405 of file perf_log.h.

References tot_time, tot_time_incl_sub, tstart, and tstart_incl_sub.

Referenced by pause(), and stopit().

406 {
407  // save the start times, reuse the structure we have rather than create
408  // a new one.
409  const time_t
410  tstart_tv_sec = this->tstart.tv_sec,
411  tstart_tv_usec = this->tstart.tv_usec;
412 
413  gettimeofday (&(this->tstart), nullptr);
414 
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);
417 
418  this->tot_time += elapsed_time;
419 
420  if (do_stop)
421  {
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);
424 
425  this->tot_time_incl_sub += elapsed_time_incl_sub;
426  }
427 
428  return elapsed_time;
429 }
double tot_time_incl_sub
Definition: perf_log.h:72
struct timeval tstart
Definition: perf_log.h:78
struct timeval tstart_incl_sub
Definition: perf_log.h:84
double tot_time
Definition: perf_log.h:67

◆ stopit()

double libMesh::PerfData::stopit ( )
inline

Definition at line 452 of file perf_log.h.

References called_recursively, and stop_or_pause().

453 {
454  // stopit is just similar to pause except that it decrements the
455  // recursive call counter
456 
457  this->called_recursively--;
458  return this->stop_or_pause(true);
459 }
int called_recursively
Definition: perf_log.h:105
double stop_or_pause(const bool do_stop)
Definition: perf_log.h:405

Member Data Documentation

◆ called_recursively

int libMesh::PerfData::called_recursively

Definition at line 105 of file perf_log.h.

Referenced by pause_for(), start(), and stopit().

◆ count

unsigned int libMesh::PerfData::count

The number of times this event has been executed

Definition at line 90 of file perf_log.h.

Referenced by libMesh::PerfLog::get_perf_info(), pause_for(), and start().

◆ open

bool libMesh::PerfData::open

Flag indicating if we are currently monitoring this event. Should only be true while the event is executing.

Definition at line 97 of file perf_log.h.

◆ tot_time

double libMesh::PerfData::tot_time

Total time spent in this event.

Definition at line 67 of file perf_log.h.

Referenced by libMesh::PerfLog::get_perf_info(), pause_for(), and stop_or_pause().

◆ tot_time_incl_sub

double libMesh::PerfData::tot_time_incl_sub

Total time spent in this event, including sub-events.

Definition at line 72 of file perf_log.h.

Referenced by libMesh::PerfLog::get_perf_info(), and stop_or_pause().

◆ tstart

struct timeval libMesh::PerfData::tstart

Structure defining when the event was last started.

Definition at line 78 of file perf_log.h.

Referenced by pause_for(), restart(), start(), and stop_or_pause().

◆ tstart_incl_sub

struct timeval libMesh::PerfData::tstart_incl_sub

Structure defining when the event was last started, including sub-events.

Definition at line 84 of file perf_log.h.

Referenced by pause_for(), start(), and stop_or_pause().


The documentation for this class was generated from the following file: