CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Timer.h
Go to the documentation of this file.
1 #ifndef L1Trigger_TrackFindingTracklet_interface_Timer_h
2 #define L1Trigger_TrackFindingTracklet_interface_Timer_h
3 
4 #include <cmath>
5 #include <chrono>
6 
7 namespace trklet {
8 
9  class Timer {
10  public:
11  Timer() {}
12 
13  ~Timer() = default;
14 
15  void start();
16  void stop();
17  unsigned int ntimes() const { return ntimes_; }
18  double avgtime() const { return ttot_ / ntimes_; }
19  double rms() const { return sqrt((ttot_ * ttot_ - ttotsq_)) / ntimes_; }
20  double tottime() const { return ttot_; }
21 
22  private:
23  unsigned int ntimes_{0};
24  double ttot_{0.0};
25  double ttotsq_{0.0};
26 
27  std::chrono::high_resolution_clock::time_point tstart_;
28  };
29 }; // namespace trklet
30 #endif
void start()
Definition: Timer.cc:5
unsigned int ntimes() const
Definition: Timer.h:17
double tottime() const
Definition: Timer.h:20
T sqrt(T t)
Definition: SSEVec.h:19
double rms() const
Definition: Timer.h:19
double ttotsq_
Definition: Timer.h:25
double avgtime() const
Definition: Timer.h:18
double ttot_
Definition: Timer.h:24
void stop()
Definition: Timer.cc:6
unsigned int ntimes_
Definition: Timer.h:23
std::chrono::high_resolution_clock::time_point tstart_
Definition: Timer.h:27
~Timer()=default