$extrastylesheet
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().

                                          :
  id_string(id),
  verbose(v),
  proc_id(pid)
{
  reset ();
}

Definition at line 148 of file perfmon.h.

References print().

{
  print ();
}

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().

{
  gettimeofday (&the_time_stop, NULL);

#ifdef HAVE_PAPI_H
  Papi::PAPI_flops (&rtime, &ptime, &flpins, &mflops);
#endif

  const double elapsed_time = ((double) (the_time_stop.tv_sec - the_time_start.tv_sec)) +
    ((double) (the_time_stop.tv_usec - the_time_start.tv_usec))/1000000.;

  if (verbose)
    {

      if (proc_id == 0)
        {
          if (msg == "NULL")
            my_out << " " << id_string
                   << ": elapsed time: "
                   << elapsed_time << " (sec)"
                   << std::endl;
          else
            my_out << " " << msg
                   << ": elapsed time: "
                   << elapsed_time << " (sec)"
                   << std::endl;

#ifdef HAVE_PAPI_H
          if (msg == "NULL")
            my_out << " " << id_string
                   << ": mflops: "
                   << mflops
                   << std::endl;
          else
            my_out << " " << msg
                   << ": mflops: "
                   << mflops
                   << std::endl;
#endif

        }
    }

  return elapsed_time;
}
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().

{
  gettimeofday (&the_time_start, NULL);

#ifdef HAVE_PAPI_H
  Papi::PAPI_flops (&rtime, &ptime, &flpins, &mflops);
#endif
}

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 [private]

Definition at line 58 of file perfmon.h.

Referenced by print(), and reset().

struct timeval libMesh::PerfMon::the_time_stop [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: