HOPS
HOPS class reference
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
hops::MHO_Timer Class Reference

Class MHO_Timer - A timer class responsible for thread and process benchmarking For more information on the linux system variables and functions that were leveraged see: https://linux.die.net/man/3/clock_gettime TODO – detect if system actually has a realtime clock and disable if not present. More...

#include <MHO_Timer.hh>

Public Member Functions

 MHO_Timer ()
 
 MHO_Timer (std::string name)
 
virtual ~MHO_Timer ()
 
double GetDurationAsDouble () const
 
timespec GetDurationAsTimeSpec () const
 
std::string GetName () const
 
double GetTimeSinceStart () const
 
void MeasureProcessTime ()
 
void MeasureThreadTime ()
 
void MeasureWallclockTime ()
 
void SetName (std::string name)
 
void Start ()
 
void Stop ()
 

Protected Member Functions

timespec GetTimeDifference (const timespec &start, const timespec &stop) const
 

Protected Attributes

clockid_t fClockID
 
std::string fName
 
timespec fStart
 
timespec fStop
 

Detailed Description

Class MHO_Timer - A timer class responsible for thread and process benchmarking For more information on the linux system variables and functions that were leveraged see: https://linux.die.net/man/3/clock_gettime TODO – detect if system actually has a realtime clock and disable if not present.

Author
J. Barrett - barre.nosp@m.ttj@.nosp@m.mit.e.nosp@m.du

Constructor & Destructor Documentation

◆ MHO_Timer() [1/2]

hops::MHO_Timer::MHO_Timer ( )

◆ MHO_Timer() [2/2]

hops::MHO_Timer::MHO_Timer ( std::string  name)

◆ ~MHO_Timer()

hops::MHO_Timer::~MHO_Timer ( )
virtual

Member Function Documentation

◆ GetDurationAsDouble()

double hops::MHO_Timer::GetDurationAsDouble ( ) const
  • Call GetTimeDifference and return the result as a double
    Parameters
    None
    Returns
    ret_val double which contains the start and stop time in seconds

◆ GetDurationAsTimeSpec()

timespec hops::MHO_Timer::GetDurationAsTimeSpec ( ) const
  • Call GetTimeDifference and return the result as a timespec struct
    Parameters
    None
    Returns
    ret_val timespec which is a struct containing the start and stop time in seconds and nanoseconds as two seperate values

◆ GetName()

std::string hops::MHO_Timer::GetName ( ) const
inline
  • Get the timer name
    Parameters
    None
    Returns
    fName string timer name

◆ GetTimeDifference()

timespec hops::MHO_Timer::GetTimeDifference ( const timespec &  start,
const timespec &  stop 
) const
protected
  • Calculate total compute time spent on a process or thread and store the result in a timespec struct
    Parameters
    starttimespec which is the start time for a process or thread
    stoptimespec which is the start time for a process or thread
    Returns
    ret_val timespec which contains the time spent on a given process or thread in seconds and nanoseconds

◆ GetTimeSinceStart()

double hops::MHO_Timer::GetTimeSinceStart ( ) const

◆ MeasureProcessTime()

void hops::MHO_Timer::MeasureProcessTime ( )
  • Get the ID for the process clock
    Parameters
    None
    Returns
    None

◆ MeasureThreadTime()

void hops::MHO_Timer::MeasureThreadTime ( )
  • Get the ID for the thread clock which indicates the time used by all threads in the process
    Parameters
    None
    Returns
    None

◆ MeasureWallclockTime()

void hops::MHO_Timer::MeasureWallclockTime ( )
  • Set the timer's clock ID to that of the linux system wide realtime clock
    Parameters
    None
    Returns
    None

◆ SetName()

void hops::MHO_Timer::SetName ( std::string  name)
inline

Set the timer name

Parameters
namestring
Returns
None

◆ Start()

void hops::MHO_Timer::Start ( )
  • Store the current linux system time as the start time of a timer in a timespec struct
    Parameters
    None
    Returns
    None

◆ Stop()

void hops::MHO_Timer::Stop ( )
  • Store the current linux system time as the stop time of a timer in a timespec struct
    Parameters
    None
    Returns
    None

Member Data Documentation

◆ fClockID

clockid_t hops::MHO_Timer::fClockID
protected

◆ fName

std::string hops::MHO_Timer::fName
protected

◆ fStart

timespec hops::MHO_Timer::fStart
protected

◆ fStop

timespec hops::MHO_Timer::fStop
protected

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