libMesh
Public Member Functions | Public Attributes | Protected Member Functions | List of all members
libMesh::PerfData Class Reference

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

#include <perf_log.h>

Public Member Functions

 PerfData ()
 Constructor. More...
 
void start ()
 
void restart ()
 
double pause ()
 
double pause_for (PerfData &other)
 
double stopit ()
 
PerfDataoperator+= (const PerfData &other)
 Sums timing results from other. More...
 

Public Attributes

double tot_time
 Total time spent in this event. More...
 
double tot_time_incl_sub
 Total time spent in this event, including sub-events. More...
 
struct timeval tstart
 Structure defining when the event was last started. More...
 
struct timeval tstart_incl_sub
 Structure defining when the event was last started, including sub-events. More...
 
unsigned int count
 The number of times this event has been executed. More...
 
bool open
 Flag indicating if we are currently monitoring this event. More...
 
int called_recursively
 

Protected Member Functions

double stop_or_pause (const bool do_stop)
 

Detailed Description

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

Author
Benjamin Kirk
Date
2003 Data object managed by PerfLog

Definition at line 53 of file perf_log.h.

Constructor & Destructor Documentation

◆ PerfData()

libMesh::PerfData::PerfData ( )
inline

Constructor.

Initializes data to be empty.

Definition at line 60 of file perf_log.h.

60  :
61  tot_time(0.),
63  tstart(),
65  count(0),
66  open(false),
68  {}
double tot_time_incl_sub
Total time spent in this event, including sub-events.
Definition: perf_log.h:79
int called_recursively
Definition: perf_log.h:125
struct timeval tstart
Structure defining when the event was last started.
Definition: perf_log.h:85
struct timeval tstart_incl_sub
Structure defining when the event was last started, including sub-events.
Definition: perf_log.h:91
double tot_time
Total time spent in this event.
Definition: perf_log.h:74
unsigned int count
The number of times this event has been executed.
Definition: perf_log.h:97
bool open
Flag indicating if we are currently monitoring this event.
Definition: perf_log.h:104

Member Function Documentation

◆ operator+=()

PerfData& libMesh::PerfData::operator+= ( const PerfData other)
inline

Sums timing results from other.

Definition at line 115 of file perf_log.h.

References count, libMesh::libmesh_assert(), open, tot_time, and tot_time_incl_sub.

116  {
118  tot_time += other.tot_time;
119  tot_time_incl_sub += other.tot_time_incl_sub;
120  count += other.count;
121 
122  return *this;
123  }
double tot_time_incl_sub
Total time spent in this event, including sub-events.
Definition: perf_log.h:79
libmesh_assert(ctx)
double tot_time
Total time spent in this event.
Definition: perf_log.h:74
unsigned int count
The number of times this event has been executed.
Definition: perf_log.h:97
bool open
Flag indicating if we are currently monitoring this event.
Definition: perf_log.h:104

◆ pause()

double libMesh::PerfData::pause ( )
inline

Definition at line 426 of file perf_log.h.

427 {
428  return this->stop_or_pause(false);
429 }
double stop_or_pause(const bool do_stop)
Definition: perf_log.h:433

◆ pause_for()

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

Definition at line 462 of file perf_log.h.

References called_recursively, count, gettimeofday(), tstart, libMesh::PerfLog::tstart, tstart_incl_sub, timeval::tv_sec, and timeval::tv_usec.

463 {
464  gettimeofday (&(other.tstart), nullptr);
465 
466  const double elapsed_time = (static_cast<double>(other.tstart.tv_sec - this->tstart.tv_sec) +
467  static_cast<double>(other.tstart.tv_usec - this->tstart.tv_usec)*1.e-6);
468  this->tot_time += elapsed_time;
469 
470  other.count++;
471  other.called_recursively++;
472  other.tstart_incl_sub = other.tstart;
473 
474  return elapsed_time;
475 }
int gettimeofday(struct timeval *tp, struct timezone *tzp)
struct timeval tstart
Structure defining when the event was last started.
Definition: perf_log.h:85
double tot_time
Total time spent in this event.
Definition: perf_log.h:74

◆ restart()

void libMesh::PerfData::restart ( )
inline

Definition at line 418 of file perf_log.h.

References gettimeofday(), and libMesh::PerfLog::tstart.

419 {
420  gettimeofday (&(this->tstart), nullptr);
421 }
int gettimeofday(struct timeval *tp, struct timezone *tzp)
struct timeval tstart
Structure defining when the event was last started.
Definition: perf_log.h:85

◆ start()

void libMesh::PerfData::start ( )
inline

Definition at line 407 of file perf_log.h.

References gettimeofday(), and libMesh::PerfLog::tstart.

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

408 {
409  this->count++;
410  this->called_recursively++;
411  gettimeofday (&(this->tstart), nullptr);
412  this->tstart_incl_sub = this->tstart;
413 }
int called_recursively
Definition: perf_log.h:125
int gettimeofday(struct timeval *tp, struct timezone *tzp)
struct timeval tstart
Structure defining when the event was last started.
Definition: perf_log.h:85
struct timeval tstart_incl_sub
Structure defining when the event was last started, including sub-events.
Definition: perf_log.h:91
unsigned int count
The number of times this event has been executed.
Definition: perf_log.h:97

◆ stop_or_pause()

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

Definition at line 433 of file perf_log.h.

References gettimeofday(), libMesh::PerfLog::tstart, timeval::tv_sec, and timeval::tv_usec.

434 {
435  // save the start times, reuse the structure we have rather than create
436  // a new one.
437  const time_t
438  tstart_tv_sec = this->tstart.tv_sec,
439  tstart_tv_usec = this->tstart.tv_usec;
440 
441  gettimeofday (&(this->tstart), nullptr);
442 
443  const double elapsed_time = (static_cast<double>(this->tstart.tv_sec - tstart_tv_sec) +
444  static_cast<double>(this->tstart.tv_usec - tstart_tv_usec)*1.e-6);
445 
446  this->tot_time += elapsed_time;
447 
448  if (do_stop)
449  {
450  const double elapsed_time_incl_sub = (static_cast<double>(this->tstart.tv_sec - this->tstart_incl_sub.tv_sec) +
451  static_cast<double>(this->tstart.tv_usec - this->tstart_incl_sub.tv_usec)*1.e-6);
452 
453  this->tot_time_incl_sub += elapsed_time_incl_sub;
454  }
455 
456  return elapsed_time;
457 }
double tot_time_incl_sub
Total time spent in this event, including sub-events.
Definition: perf_log.h:79
int gettimeofday(struct timeval *tp, struct timezone *tzp)
struct timeval tstart
Structure defining when the event was last started.
Definition: perf_log.h:85
struct timeval tstart_incl_sub
Structure defining when the event was last started, including sub-events.
Definition: perf_log.h:91
double tot_time
Total time spent in this event.
Definition: perf_log.h:74

◆ stopit()

double libMesh::PerfData::stopit ( )
inline

Definition at line 480 of file perf_log.h.

481 {
482  // stopit is just similar to pause except that it decrements the
483  // recursive call counter
484 
485  this->called_recursively--;
486  return this->stop_or_pause(true);
487 }
int called_recursively
Definition: perf_log.h:125
double stop_or_pause(const bool do_stop)
Definition: perf_log.h:433

Member Data Documentation

◆ called_recursively

int libMesh::PerfData::called_recursively

Definition at line 125 of file perf_log.h.

Referenced by pause_for().

◆ count

unsigned int libMesh::PerfData::count

The number of times this event has been executed.

Definition at line 97 of file perf_log.h.

Referenced by libMesh::PerfLog::get_perf_info(), operator+=(), and pause_for().

◆ 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 104 of file perf_log.h.

Referenced by operator+=().

◆ tot_time

double libMesh::PerfData::tot_time

Total time spent in this event.

Definition at line 74 of file perf_log.h.

Referenced by libMesh::PerfLog::get_perf_info(), and operator+=().

◆ tot_time_incl_sub

double libMesh::PerfData::tot_time_incl_sub

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

Definition at line 79 of file perf_log.h.

Referenced by libMesh::PerfLog::get_perf_info(), and operator+=().

◆ tstart

struct timeval libMesh::PerfData::tstart

Structure defining when the event was last started.

Definition at line 85 of file perf_log.h.

Referenced by pause_for().

◆ tstart_incl_sub

struct timeval libMesh::PerfData::tstart_incl_sub

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

Definition at line 91 of file perf_log.h.

Referenced by pause_for().


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