libMesh::PerfMon Class Reference

#include <perfmon.h>

List of all members.

Public Member Functions

 PerfMon (std::string id, const unsigned int v=1, const unsigned int pid=0)
 ~PerfMon ()
void reset ()
double print (std::string msg="NULL", std::ostream &out=libMesh::out)

Private Attributes

const std::string id_string
struct timeval the_time_start
struct timeval the_time_stop
const unsigned int verbose
const unsigned int proc_id
float rtime
float ptime
float mflops
long long int flpins

Detailed Description

Definition at line 43 of file perfmon.h.


Constructor & Destructor Documentation

libMesh::PerfMon::PerfMon ( std::string  id,
const unsigned int  v = 1,
const unsigned int  pid = 0 
) [inline]

Definition at line 135 of file perfmon.h.

References reset().

00137                                           :
00138   id_string(id),
00139   verbose(v),
00140   proc_id(pid)
00141 {
00142   reset ();
00143 }

libMesh::PerfMon::~PerfMon (  )  [inline]

Definition at line 148 of file perfmon.h.

References print().

00149 {
00150   print ();
00151 }


Member Function Documentation

double libMesh::PerfMon::print ( std::string  msg = "NULL",
std::ostream &  out = libMesh::out 
) [inline]

Definition at line 87 of file perfmon.h.

References flpins, id_string, mflops, proc_id, ptime, rtime, the_time_start, the_time_stop, and verbose.

Referenced by ~PerfMon().

00088 {
00089   gettimeofday (&the_time_stop, NULL);
00090 
00091 #ifdef HAVE_PAPI_H
00092   Papi::PAPI_flops (&rtime, &ptime, &flpins, &mflops);
00093 #endif
00094 
00095   const double elapsed_time = ((double) (the_time_stop.tv_sec - the_time_start.tv_sec)) +
00096                               ((double) (the_time_stop.tv_usec - the_time_start.tv_usec))/1000000.;
00097 
00098   if (verbose)
00099     {
00100 
00101       if (proc_id == 0)
00102         {
00103           if (msg == "NULL")
00104             my_out << " " << id_string
00105                    << ": elapsed time: "
00106                    << elapsed_time << " (sec)"
00107                    << std::endl;
00108           else
00109             my_out << " " << msg
00110                    << ": elapsed time: "
00111                    << elapsed_time << " (sec)"
00112                    << std::endl;
00113 
00114 #ifdef HAVE_PAPI_H
00115           if (msg == "NULL")
00116             my_out << " " << id_string
00117                    << ": mflops: "
00118                    << mflops
00119                    << std::endl;
00120           else
00121             my_out << " " << msg
00122                    << ": mflops: "
00123                    << mflops
00124                    << std::endl;
00125 #endif
00126 
00127         }
00128     }
00129 
00130   return elapsed_time;
00131 }

void libMesh::PerfMon::reset (  )  [inline]

Definition at line 74 of file perfmon.h.

References flpins, mflops, ptime, rtime, and the_time_start.

Referenced by PerfMon().

00075 {
00076   gettimeofday (&the_time_start, NULL);
00077 
00078 #ifdef HAVE_PAPI_H
00079   Papi::PAPI_flops (&rtime, &ptime, &flpins, &mflops);
00080 #endif
00081 }


Member Data Documentation

long long int libMesh::PerfMon::flpins [private]

Definition at line 66 of file perfmon.h.

Referenced by print(), and reset().

const std::string libMesh::PerfMon::id_string [private]

Definition at line 56 of file perfmon.h.

Referenced by print().

float libMesh::PerfMon::mflops [private]

Definition at line 65 of file perfmon.h.

Referenced by print(), and reset().

const unsigned int libMesh::PerfMon::proc_id [private]

Definition at line 62 of file perfmon.h.

Referenced by print().

float libMesh::PerfMon::ptime [private]

Definition at line 65 of file perfmon.h.

Referenced by print(), and reset().

float libMesh::PerfMon::rtime [private]

Definition at line 65 of file perfmon.h.

Referenced by print(), and reset().

struct timeval libMesh::PerfMon::the_time_start [read, private]

Definition at line 58 of file perfmon.h.

Referenced by print(), and reset().

struct timeval libMesh::PerfMon::the_time_stop [read, private]

Definition at line 59 of file perfmon.h.

Referenced by print().

const unsigned int libMesh::PerfMon::verbose [private]

Definition at line 61 of file perfmon.h.

Referenced by print().


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

Site Created By: libMesh Developers
Last modified: February 05 2013 19:55:33 UTC

Hosted By:
SourceForge.net Logo