Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:21:55

0001 #ifndef L1Trigger_TrackFindingTracklet_interface_Timer_h
0002 #define L1Trigger_TrackFindingTracklet_interface_Timer_h
0003 
0004 #include <cmath>
0005 #include <chrono>
0006 
0007 namespace trklet {
0008 
0009   class Timer {
0010   public:
0011     Timer() {}
0012 
0013     ~Timer() = default;
0014 
0015     void start();
0016     void stop();
0017     unsigned int ntimes() const { return ntimes_; }
0018     double avgtime() const { return ttot_ / ntimes_; }
0019     double rms() const { return sqrt((ttot_ * ttot_ - ttotsq_)) / ntimes_; }
0020     double tottime() const { return ttot_; }
0021 
0022   private:
0023     unsigned int ntimes_{0};
0024     double ttot_{0.0};
0025     double ttotsq_{0.0};
0026 
0027     std::chrono::high_resolution_clock::time_point tstart_;
0028   };
0029 };  // namespace trklet
0030 #endif