File indexing completed on 2023-03-17 11:03:52
0001 #ifndef FWCore_Utilities_WallclockTimer_h
0002 #define FWCore_Utilities_WallclockTimer_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 #ifdef __linux__
0023
0024 #define USE_CLOCK_GETTIME
0025 #endif
0026
0027 #ifdef USE_CLOCK_GETTIME
0028 #include <ctime>
0029 #else
0030 #include <sys/time.h>
0031 #endif
0032
0033
0034
0035
0036 namespace edm {
0037 class WallclockTimer {
0038 public:
0039 WallclockTimer();
0040 ~WallclockTimer();
0041 WallclockTimer(WallclockTimer&&) = default;
0042 WallclockTimer(const WallclockTimer&) = delete;
0043 WallclockTimer& operator=(const WallclockTimer&) = delete;
0044
0045
0046 double realTime() const;
0047
0048
0049
0050
0051 void start();
0052 double stop();
0053 void reset();
0054
0055 void add(double t);
0056
0057 private:
0058 double calculateDeltaTime() const;
0059
0060
0061 enum State { kRunning, kStopped } state_;
0062 #ifdef USE_CLOCK_GETTIME
0063 struct timespec startRealTime_;
0064 #else
0065 struct timeval startRealTime_;
0066 #endif
0067
0068 double accumulatedRealTime_;
0069 };
0070 }
0071
0072 #endif