Class Reference for E1039 Core & Analysis Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PHTimer2 Class Reference

Class to measure the time spent by a code block. More...

#include </dev/shm/kenichi/update-github-e1039-doc/e1039-core/framework/phool/PHTimer2.h>

Public Member Functions

 PHTimer2 (const std::string &name="Generic Timer")
 
virtual ~PHTimer2 ()
 
void set_name (const std::string &name)
 
std::string get_name () const
 
double get_accumulated_time () const
 
unsigned int get_ncycle () const
 
double get_time_per_cycle () const
 
void reset ()
 
void stop ()
 
void restart ()
 
void reset_and_start ()
 
void print_stat (std::string header=" Timer2:", std::ostream &os=std::cout) const
 
void test (unsigned int time_msec, std::ostream &os=std::cout)
 Test this class by waiting for a given time (in ms). More...
 

Protected Member Functions

double elapsed () const
 In millisecond. More...
 
int get_clock_time (timespec *tp)
 

Detailed Description

Class to measure the time spent by a code block.

It is a new (2nd) version of PHTimer. PHTimer was found to have two problems as of 2022-05-13:

  • It breaks the pthread mutex (i.e. pthread_mutex_unlock() fails), probably because PHTimer uses the assembly call.
  • The measured time is longer than the actual time by 30-80%, probably because the CPU frequency is changing.

Definition at line 16 of file PHTimer2.h.

Constructor & Destructor Documentation

◆ PHTimer2()

PHTimer2::PHTimer2 ( const std::string &  name = "Generic Timer")

Definition at line 7 of file PHTimer2.cc.

◆ ~PHTimer2()

PHTimer2::~PHTimer2 ( )
virtual

Definition at line 16 of file PHTimer2.cc.

Member Function Documentation

◆ elapsed()

double PHTimer2::elapsed ( void  ) const
protected

In millisecond.

Definition at line 72 of file PHTimer2.cc.

Referenced by stop().

+ Here is the caller graph for this function:

◆ get_accumulated_time()

double PHTimer2::get_accumulated_time ( void  ) const
inline

Definition at line 34 of file PHTimer2.h.

Referenced by Fun4AllServer::ReadSpillTimer().

+ Here is the caller graph for this function:

◆ get_clock_time()

int PHTimer2::get_clock_time ( timespec *  tp)
protected

Definition at line 82 of file PHTimer2.cc.

Referenced by restart(), and stop().

+ Here is the caller graph for this function:

◆ get_name()

std::string PHTimer2::get_name ( void  ) const
inline

Definition at line 32 of file PHTimer2.h.

◆ get_ncycle()

unsigned int PHTimer2::get_ncycle ( ) const
inline

Definition at line 35 of file PHTimer2.h.

◆ get_time_per_cycle()

double PHTimer2::get_time_per_cycle ( void  ) const

Definition at line 21 of file PHTimer2.cc.

Referenced by print_stat().

+ Here is the caller graph for this function:

◆ print_stat()

void PHTimer2::print_stat ( std::string  header = "  Timer2:",
std::ostream &  os = std::cout 
) const

Definition at line 54 of file PHTimer2.cc.

References get_time_per_cycle().

+ Here is the call graph for this function:

◆ reset()

void PHTimer2::reset ( )

Definition at line 26 of file PHTimer2.cc.

Referenced by reset_and_start(), Fun4AllServer::ResetSpillTimer(), and test().

+ Here is the caller graph for this function:

◆ reset_and_start()

void PHTimer2::reset_and_start ( )

Definition at line 48 of file PHTimer2.cc.

References reset(), and restart().

+ Here is the call graph for this function:

◆ restart()

void PHTimer2::restart ( )

Definition at line 42 of file PHTimer2.cc.

References get_clock_time().

Referenced by Fun4AllServer::process_event(), reset_and_start(), and test().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ set_name()

void PHTimer2::set_name ( const std::string &  name)
inline

Definition at line 31 of file PHTimer2.h.

◆ stop()

void PHTimer2::stop ( )

Definition at line 33 of file PHTimer2.cc.

References elapsed(), and get_clock_time().

Referenced by Fun4AllServer::process_event(), and test().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ test()

void PHTimer2::test ( unsigned int  time_msec,
std::ostream &  os = std::cout 
)

Test this class by waiting for a given time (in ms).

Definition at line 62 of file PHTimer2.cc.

References reset(), restart(), and stop().

+ Here is the call graph for this function:

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