Public Member Functions | Private Attributes | List of all members
cet::cpu_timer Class Reference

#include <cpu_timer.h>

Public Member Functions

 cpu_timer ()=default
 
 cpu_timer (cpu_timer &&)=default
 
cpu_timeroperator= (cpu_timer &&)=default
 
 cpu_timer (cpu_timer const &)=delete
 
cpu_timeroperator= (cpu_timer const &)=delete
 
bool is_running () const
 
bool is_stopped () const
 
double elapsed_real_time () const
 
double elapsed_cpu_time () const
 
double accumulated_real_time () const
 
double accumulated_cpu_time () const
 
double realTime () const
 
double cpuTime () const
 
void start ()
 
void stop ()
 
void reset ()
 

Private Attributes

bool is_running_ {false}
 
timeval start_real_time_ {0, 0}
 
timeval start_cpu_time_ {0, 0}
 
double accumulated_real_time_ {}
 
double accumulated_cpu_time_ {}
 

Detailed Description

Definition at line 18 of file cpu_timer.h.

Constructor & Destructor Documentation

cet::cpu_timer::cpu_timer ( )
default
cet::cpu_timer::cpu_timer ( cpu_timer &&  )
default
cet::cpu_timer::cpu_timer ( cpu_timer const &  )
delete

Member Function Documentation

double cpu_timer::accumulated_cpu_time ( ) const

Definition at line 73 of file cpu_timer.cc.

74 {
77 }
double accumulated_cpu_time_
Definition: cpu_timer.h:60
double elapsed_cpu_time() const
Definition: cpu_timer.cc:60
bool is_stopped() const
Definition: cpu_timer.h:73
double cpu_timer::accumulated_real_time ( ) const

Definition at line 66 of file cpu_timer.cc.

67 {
70 }
double accumulated_real_time_
Definition: cpu_timer.h:59
bool is_stopped() const
Definition: cpu_timer.h:73
double elapsed_real_time() const
Definition: cpu_timer.cc:54
double cet::cpu_timer::cpuTime ( ) const
inline

Definition at line 44 of file cpu_timer.h.

45  {
46  return accumulated_cpu_time();
47  }
double accumulated_cpu_time() const
Definition: cpu_timer.cc:73
double cpu_timer::elapsed_cpu_time ( ) const

Definition at line 60 of file cpu_timer.cc.

61 {
62  return cpu_now() - start_cpu_time_;
63 }
timeval start_cpu_time_
Definition: cpu_timer.h:58
double cpu_timer::elapsed_real_time ( ) const

Definition at line 54 of file cpu_timer.cc.

55 {
56  return real_now() - start_real_time_;
57 }
timeval start_real_time_
Definition: cpu_timer.h:57
bool cet::cpu_timer::is_running ( ) const
inline

Definition at line 67 of file cpu_timer.h.

68 {
69  return is_running_;
70 }
bool is_running_
Definition: cpu_timer.h:56
bool cet::cpu_timer::is_stopped ( ) const
inline

Definition at line 73 of file cpu_timer.h.

74 {
75  return !is_running();
76 }
bool is_running() const
Definition: cpu_timer.h:67
cpu_timer& cet::cpu_timer::operator= ( cpu_timer &&  )
default
cpu_timer& cet::cpu_timer::operator= ( cpu_timer const &  )
delete
double cet::cpu_timer::realTime ( ) const
inline

Definition at line 39 of file cpu_timer.h.

40  {
41  return accumulated_real_time();
42  }
double accumulated_real_time() const
Definition: cpu_timer.cc:66
void cpu_timer::reset ( )

Definition at line 103 of file cpu_timer.cc.

104 {
106  accumulated_cpu_time_ = 0.0;
107 }
double accumulated_cpu_time_
Definition: cpu_timer.h:60
double accumulated_real_time_
Definition: cpu_timer.h:59
void cpu_timer::start ( )

Definition at line 83 of file cpu_timer.cc.

84 {
85  if (!is_stopped())
86  return;
87  start_real_time_ = real_now();
88  start_cpu_time_ = cpu_now();
89  is_running_ = true;
90 }
timeval start_cpu_time_
Definition: cpu_timer.h:58
timeval start_real_time_
Definition: cpu_timer.h:57
bool is_running_
Definition: cpu_timer.h:56
bool is_stopped() const
Definition: cpu_timer.h:73
void cpu_timer::stop ( )

Definition at line 93 of file cpu_timer.cc.

94 {
95  if (!is_running())
96  return;
99  is_running_ = false;
100 }
double accumulated_cpu_time_
Definition: cpu_timer.h:60
bool is_running() const
Definition: cpu_timer.h:67
bool is_running_
Definition: cpu_timer.h:56
double elapsed_cpu_time() const
Definition: cpu_timer.cc:60
double accumulated_real_time_
Definition: cpu_timer.h:59
double elapsed_real_time() const
Definition: cpu_timer.cc:54

Member Data Documentation

double cet::cpu_timer::accumulated_cpu_time_ {}
private

Definition at line 60 of file cpu_timer.h.

double cet::cpu_timer::accumulated_real_time_ {}
private

Definition at line 59 of file cpu_timer.h.

bool cet::cpu_timer::is_running_ {false}
private

Definition at line 56 of file cpu_timer.h.

timeval cet::cpu_timer::start_cpu_time_ {0, 0}
private

Definition at line 58 of file cpu_timer.h.

timeval cet::cpu_timer::start_real_time_ {0, 0}
private

Definition at line 57 of file cpu_timer.h.


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