File indexing completed on 2024-04-06 12:13:11
0001 #ifndef FWCore_Utilities_ChildrenCPUTimer_h
0002 #define FWCore_Utilities_ChildrenCPUTimer_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 #include <sys/time.h>
0023
0024
0025
0026
0027 namespace edm {
0028 class ChildrenCPUTimer {
0029 public:
0030 ChildrenCPUTimer();
0031 ~ChildrenCPUTimer();
0032 ChildrenCPUTimer(ChildrenCPUTimer&&) = default;
0033 ChildrenCPUTimer(const ChildrenCPUTimer&) = delete;
0034 ChildrenCPUTimer& operator=(const ChildrenCPUTimer&) = delete;
0035
0036
0037 double cpuTime() const;
0038
0039
0040
0041
0042 void start();
0043 double stop();
0044 void reset();
0045
0046 void add(double t);
0047
0048 private:
0049 double calculateDeltaTime() const;
0050
0051
0052 enum State { kRunning, kStopped } state_;
0053 struct timeval startCPUTime_;
0054
0055 double accumulatedCPUTime_;
0056 };
0057 }
0058
0059 #endif