Stopwatch Class Reference

An accurate software stopwatch. More...

#include <Stopwatch.h>

List of all members.

Public Member Functions

 Stopwatch ()
 Creates an instance of the stopwatch that is zeroed and not running.
void reset ()
 Resets and stops the stopwatch.
void start ()
 Starts the stopwatch.
void stop ()
 Stops the stopwatch.
void lap ()
void print (string title)
longType timeMS ()
 Gets the time in milliseconds.
longType timeUS ()
 Gets the time in microseconds.
bool isRunning ()
 Returns true if the stopwatch is running and false otherwise.
string toString ()
 Gets the time formatted as a string.
void operator= (const Stopwatch &rhs)
 Sets two objects equal.
Stopwatch operator+ (Stopwatch &rhs)
 Returns a stopwatch which contains the total time from two stopwatch objects.

Static Public Attributes

static MPI_Datatype MPI_TYPE
 The MPI data type for a Stopwatch.
static MPI_Op MPI_REDUCE
 The MPI operation for performing MPI_Reduce on Stopwatch objects.

Static Private Member Functions

static void buildMpiType ()
 Build MPI_TYPE.
static void buildMpiReduce ()
 Build MPI_REDUCE.
static void Reduce_Function (Stopwatch *in, Stopwatch *inout, int *len, MPI_Datatype *dptr)
 An MPI function which allows MPI_Reduce to be used in adding Stopwatches.

Private Attributes

longType stime1
longType stime2
longType result_us
longType total_us
microType micro1
microType micro2
bool running
longType average_us
int numSamples
struct timeval tp
struct timezone tz

Static Private Attributes

static bool mpiTypeCreated = false
 A flag which tells if MPI_TYPE has been generated.

Friends

ostream & operator<< (ostream &strm, Stopwatch &watch)
 Formats and prints the time to a stream.


Detailed Description

An accurate software stopwatch.

Definition at line 106 of file Stopwatch.h.


Constructor & Destructor Documentation

Stopwatch::Stopwatch (  ) 

Creates an instance of the stopwatch that is zeroed and not running.

Definition at line 34 of file Stopwatch.cpp.

References buildMpiReduce(), buildMpiType(), mpiTypeCreated, reset(), and tz.


Member Function Documentation

void Stopwatch::reset (  ) 

void Stopwatch::start (  ) 

void Stopwatch::stop (  ) 

void Stopwatch::lap (  ) 

Definition at line 102 of file Stopwatch.cpp.

References average_us, micro1, micro2, numSamples, result_us, running, stime1, stime2, total_us, tp, and tz.

void Stopwatch::print ( string  title  ) 

Definition at line 128 of file Stopwatch.cpp.

References average_us, numSamples, and total_us.

longType Stopwatch::timeMS (  ) 

Gets the time in milliseconds.

Definition at line 138 of file Stopwatch.cpp.

References total_us.

Referenced by toString().

longType Stopwatch::timeUS (  ) 

Gets the time in microseconds.

Definition at line 143 of file Stopwatch.cpp.

References total_us.

Referenced by QMCSlater::evaluate(), QMCSCFJastrow::evaluate(), QMCJastrow::evaluate(), operator<<(), and QMCManager::writeTimingData().

bool Stopwatch::isRunning (  ) 

Returns true if the stopwatch is running and false otherwise.

Definition at line 148 of file Stopwatch.cpp.

References running.

Referenced by QMCStopwatches::stop(), QMCEquilibrationArray::stopTimers(), and toString().

string Stopwatch::toString (  ) 

Gets the time formatted as a string.

Definition at line 153 of file Stopwatch.cpp.

References isRunning(), micro1, micro2, stime1, stime2, timeMS(), tp, and tz.

Referenced by operator<<().

void Stopwatch::operator= ( const Stopwatch rhs  ) 

Sets two objects equal.

Definition at line 181 of file Stopwatch.cpp.

References total_us.

Stopwatch Stopwatch::operator+ ( Stopwatch rhs  ) 

Returns a stopwatch which contains the total time from two stopwatch objects.

Definition at line 189 of file Stopwatch.cpp.

References running, and total_us.

void Stopwatch::buildMpiType (  )  [static, private]

Build MPI_TYPE.

Definition at line 217 of file Stopwatch.cpp.

References MPI_TYPE, and total_us.

Referenced by Stopwatch().

void Stopwatch::buildMpiReduce (  )  [static, private]

Build MPI_REDUCE.

Definition at line 211 of file Stopwatch.cpp.

References MPI_REDUCE, and Reduce_Function().

Referenced by Stopwatch().

void Stopwatch::Reduce_Function ( Stopwatch in,
Stopwatch inout,
int *  len,
MPI_Datatype *  dptr 
) [static, private]

An MPI function which allows MPI_Reduce to be used in adding Stopwatches.

Definition at line 246 of file Stopwatch.cpp.

Referenced by buildMpiReduce().


Friends And Related Function Documentation

ostream& operator<< ( ostream &  strm,
Stopwatch watch 
) [friend]

Formats and prints the time to a stream.

Definition at line 199 of file Stopwatch.cpp.


Member Data Documentation

Definition at line 109 of file Stopwatch.h.

Referenced by lap(), reset(), start(), stop(), and toString().

Definition at line 109 of file Stopwatch.h.

Referenced by lap(), stop(), and toString().

Definition at line 109 of file Stopwatch.h.

Referenced by lap(), and stop().

Definition at line 109 of file Stopwatch.h.

Referenced by buildMpiType(), lap(), operator+(), operator=(), print(), reset(), stop(), timeMS(), and timeUS().

Definition at line 110 of file Stopwatch.h.

Referenced by lap(), reset(), start(), stop(), and toString().

Definition at line 110 of file Stopwatch.h.

Referenced by lap(), stop(), and toString().

bool Stopwatch::running [private]

Definition at line 111 of file Stopwatch.h.

Referenced by isRunning(), lap(), operator+(), reset(), start(), and stop().

Definition at line 113 of file Stopwatch.h.

Referenced by lap(), print(), and reset().

int Stopwatch::numSamples [private]

Definition at line 114 of file Stopwatch.h.

Referenced by lap(), print(), and reset().

struct timeval Stopwatch::tp [read, private]

Definition at line 116 of file Stopwatch.h.

Referenced by lap(), start(), stop(), and toString().

struct timezone Stopwatch::tz [read, private]

Definition at line 117 of file Stopwatch.h.

Referenced by lap(), start(), stop(), Stopwatch(), and toString().

bool Stopwatch::mpiTypeCreated = false [static, private]

A flag which tells if MPI_TYPE has been generated.

Definition at line 200 of file Stopwatch.h.

Referenced by Stopwatch().

MPI_Datatype Stopwatch::MPI_TYPE [static]

The MPI data type for a Stopwatch.

Definition at line 228 of file Stopwatch.h.

Referenced by buildMpiType(), and QMCStopwatches::buildMpiType().

MPI_Op Stopwatch::MPI_REDUCE [static]

The MPI operation for performing MPI_Reduce on Stopwatch objects.

Definition at line 235 of file Stopwatch.h.

Referenced by buildMpiReduce().


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

Generated on Sat Jul 5 16:14:07 2008 for QMcBeaver by  doxygen 1.5.6