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 ()
 
PerfData & operator+= (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 447 of file perf_log.h.

448{
449 return this->stop_or_pause(false);
450}
double stop_or_pause(const bool do_stop)
Definition perf_log.h:454

◆ pause_for()

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

Definition at line 483 of file perf_log.h.

484{
485 gettimeofday (&(other.tstart), nullptr);
486
487 const double elapsed_time = (static_cast<double>(other.tstart.tv_sec - this->tstart.tv_sec) +
488 static_cast<double>(other.tstart.tv_usec - this->tstart.tv_usec)*1.e-6);
489 this->tot_time += elapsed_time;
490
491 other.count++;
492 other.called_recursively++;
493 other.tstart_incl_sub = other.tstart;
494
495 return elapsed_time;
496}
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 439 of file perf_log.h.

440{
441 gettimeofday (&(this->tstart), nullptr);
442}

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

◆ start()

void libMesh::PerfData::start ( )
inline

Definition at line 428 of file perf_log.h.

429{
430 this->count++;
431 this->called_recursively++;
432 gettimeofday (&(this->tstart), nullptr);
433 this->tstart_incl_sub = this->tstart;
434}

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

455{
456 // save the start times, reuse the structure we have rather than create
457 // a new one.
458 const time_t
459 tstart_tv_sec = this->tstart.tv_sec,
460 tstart_tv_usec = this->tstart.tv_usec;
461
462 gettimeofday (&(this->tstart), nullptr);
463
464 const double elapsed_time = (static_cast<double>(this->tstart.tv_sec - tstart_tv_sec) +
465 static_cast<double>(this->tstart.tv_usec - tstart_tv_usec)*1.e-6);
466
467 this->tot_time += elapsed_time;
468
469 if (do_stop)
470 {
471 const double elapsed_time_incl_sub = (static_cast<double>(this->tstart.tv_sec - this->tstart_incl_sub.tv_sec) +
472 static_cast<double>(this->tstart.tv_usec - this->tstart_incl_sub.tv_usec)*1.e-6);
473
474 this->tot_time_incl_sub += elapsed_time_incl_sub;
475 }
476
477 return elapsed_time;
478}

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

◆ stopit()

double libMesh::PerfData::stopit ( )
inline

Definition at line 501 of file perf_log.h.

502{
503 // stopit is just similar to pause except that it decrements the
504 // recursive call counter
505
506 this->called_recursively--;
507 return this->stop_or_pause(true);
508}

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: