LArOpenCV  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
Public Member Functions | Private Attributes | List of all members
larcv::Watch Class Reference

a very simple stopwatch class for simple time measurement More...

#include <Watch.h>

Public Member Functions

 Watch ()
 
 ~Watch ()
 
void Start ()
 Start stop watch. More...
 
double WallTime ()
 Report wall-clock time [s] since Start() call. More...
 
double CPUTime ()
 Report cpu-clock time [s] since Start() call. More...
 

Private Attributes

double _cpu_time_start
 
double _wall_time_start
 

Detailed Description

a very simple stopwatch class for simple time measurement

Definition at line 27 of file Watch.h.

Constructor & Destructor Documentation

larcv::Watch::Watch ( )
inline

Definition at line 29 of file Watch.h.

29 {}
larcv::Watch::~Watch ( )
inline

Definition at line 30 of file Watch.h.

30 {}

Member Function Documentation

double larcv::Watch::CPUTime ( )
inline

Report cpu-clock time [s] since Start() call.

Definition at line 51 of file Watch.h.

References _cpu_time_start.

51  {
52  // Get cpu time
53  double now = (double)(clock());
54  // Return diff
55  return (now - _cpu_time_start)/CLOCKS_PER_SEC;
56  }
void larcv::Watch::Start ( )
inline

Start stop watch.

Definition at line 33 of file Watch.h.

References _cpu_time_start, and _wall_time_start.

Referenced by larlite::LArImageClusterBase::analyze(), larcv::ImageClusterManager::Process(), and larcv::ImageClusterBase::Process().

33  {
34  // Get current wall time
35  struct timeval current_time;
36  gettimeofday(&current_time,NULL);
37  _wall_time_start = (double)current_time.tv_sec + (double)current_time.tv_usec * 1.e-6;
38  // Get current cpu time
39  _cpu_time_start = (double)(clock());
40  }
double larcv::Watch::WallTime ( )
inline

Report wall-clock time [s] since Start() call.

Definition at line 42 of file Watch.h.

References _wall_time_start.

Referenced by larlite::LArImageClusterBase::analyze(), larcv::ImageClusterManager::Process(), and larcv::ImageClusterBase::Process().

42  {
43  // Get current wall time
44  struct timeval current_time;
45  gettimeofday(&current_time,NULL);
46  double now = (double)current_time.tv_sec + (double)current_time.tv_usec * 1.e-6;
47  // Return diff
48  return (now - _wall_time_start);
49  }

Member Data Documentation

double larcv::Watch::_cpu_time_start
private

Definition at line 58 of file Watch.h.

Referenced by CPUTime(), and Start().

double larcv::Watch::_wall_time_start
private

Definition at line 59 of file Watch.h.

Referenced by Start(), and WallTime().


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