libMesh
Loading...
Searching...
No Matches
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.
 
void start ()
 
void restart ()
 
double pause ()
 
double pause_for (PerfData &other)
 
double stopit ()
 
PerfDataoperator+= (const PerfData &other)
 Sums timing results from other.
 

Public Attributes

double tot_time
 Total time spent in this event.
 
double tot_time_incl_sub
 Total time spent in this event, including sub-events.
 
struct timeval tstart
 Structure defining when the event was last started.
 
struct timeval tstart_incl_sub
 Structure defining when the event was last started, including sub-events.
 
unsigned int count
 The number of times this event has been executed.
 
bool open
 Flag indicating if we are currently monitoring this event.
 
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 61 of file perf_log.h.

Constructor & Destructor Documentation

◆ PerfData()

libMesh::PerfData::PerfData ( )
inline

Constructor.

Initializes data to be empty.

Definition at line 68 of file perf_log.h.

68 :
69 tot_time(0.),
71 tstart(),
73 count(0),
74 open(false),
76 {}
double tot_time_incl_sub
Total time spent in this event, including sub-events.
Definition perf_log.h:87
struct timeval tstart_incl_sub
Structure defining when the event was last started, including sub-events.
Definition perf_log.h:99
double tot_time
Total time spent in this event.
Definition perf_log.h:82
unsigned int count
The number of times this event has been executed.
Definition perf_log.h:105
struct timeval tstart
Structure defining when the event was last started.
Definition perf_log.h:93
bool open
Flag indicating if we are currently monitoring this event.
Definition perf_log.h:112

Member Function Documentation

◆ operator+=()

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

Sums timing results from other.

Definition at line 123 of file perf_log.h.

124 {
126 tot_time += other.tot_time;
127 tot_time_incl_sub += other.tot_time_incl_sub;
128 count += other.count;
129
130 return *this;
131 }
libmesh_assert(ctx)

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

◆ pause()

double libMesh::PerfData::pause ( )
inline

Definition at line 434 of file perf_log.h.

435{
436 return this->stop_or_pause(false);
437}
double stop_or_pause(const bool do_stop)
Definition perf_log.h:441

◆ pause_for()

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

Definition at line 470 of file perf_log.h.

471{
472 gettimeofday (&(other.tstart), nullptr);
473
474 const double elapsed_time = (static_cast<double>(other.tstart.tv_sec - this->tstart.tv_sec) +
475 static_cast<double>(other.tstart.tv_usec - this->tstart.tv_usec)*1.e-6);
476 this->tot_time += elapsed_time;
477
478 other.count++;
479 other.called_recursively++;
480 other.tstart_incl_sub = other.tstart;
481
482 return elapsed_time;
483}
int gettimeofday(struct timeval *tp, struct timezone *tzp)

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

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

◆ restart()

void libMesh::PerfData::restart ( )
inline

Definition at line 426 of file perf_log.h.

427{
428 gettimeofday (&(this->tstart), nullptr);
429}

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

◆ start()

void libMesh::PerfData::start ( )
inline

Definition at line 415 of file perf_log.h.

416{
417 this->count++;
418 this->called_recursively++;
419 gettimeofday (&(this->tstart), nullptr);
420 this->tstart_incl_sub = this->tstart;
421}

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

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

◆ stop_or_pause()

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

Definition at line 441 of file perf_log.h.

442{
443 // save the start times, reuse the structure we have rather than create
444 // a new one.
445 const time_t
446 tstart_tv_sec = this->tstart.tv_sec,
447 tstart_tv_usec = this->tstart.tv_usec;
448
449 gettimeofday (&(this->tstart), nullptr);
450
451 const double elapsed_time = (static_cast<double>(this->tstart.tv_sec - tstart_tv_sec) +
452 static_cast<double>(this->tstart.tv_usec - tstart_tv_usec)*1.e-6);
453
454 this->tot_time += elapsed_time;
455
456 if (do_stop)
457 {
458 const double elapsed_time_incl_sub = (static_cast<double>(this->tstart.tv_sec - this->tstart_incl_sub.tv_sec) +
459 static_cast<double>(this->tstart.tv_usec - this->tstart_incl_sub.tv_usec)*1.e-6);
460
461 this->tot_time_incl_sub += elapsed_time_incl_sub;
462 }
463
464 return elapsed_time;
465}

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

◆ stopit()

double libMesh::PerfData::stopit ( )
inline

Definition at line 488 of file perf_log.h.

489{
490 // stopit is just similar to pause except that it decrements the
491 // recursive call counter
492
493 this->called_recursively--;
494 return this->stop_or_pause(true);
495}

Member Data Documentation

◆ called_recursively

int libMesh::PerfData::called_recursively

Definition at line 133 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 105 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 112 of file perf_log.h.

Referenced by operator+=().

◆ tot_time

double libMesh::PerfData::tot_time

Total time spent in this event.

Definition at line 82 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 87 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 93 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 99 of file perf_log.h.

Referenced by pause_for().


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