Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:13:11

0001 #ifndef FWCore_Utilities_ChildrenCPUTimer_h
0002 #define FWCore_Utilities_ChildrenCPUTimer_h
0003 // -*- C++ -*-
0004 //
0005 // Package:     Utilities
0006 // Class  :     ChildrenCPUTimer
0007 //
0008 /**\class ChildrenCPUTimer ChildrenCPUTimer.h FWCore/Utilities/interface/ChildrenCPUTimer.h
0009 
0010  Description: Timer which measures the CPU time for child processes
0011 
0012  Usage:
0013     <usage>
0014 
0015 */
0016 //
0017 // Original Author:  Chris Jones
0018 //         Created:  Sun Apr 16 20:32:13 EDT 2006
0019 //
0020 
0021 // system include files
0022 #include <sys/time.h>
0023 
0024 // user include files
0025 
0026 // forward declarations
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     // ---------- const member functions ---------------------
0037     double cpuTime() const;
0038 
0039     // ---------- static member functions --------------------
0040 
0041     // ---------- member functions ---------------------------
0042     void start();
0043     double stop();  //returns delta time
0044     void reset();
0045 
0046     void add(double t);
0047 
0048   private:
0049     double calculateDeltaTime() const;
0050 
0051     // ---------- member data --------------------------------
0052     enum State { kRunning, kStopped } state_;
0053     struct timeval startCPUTime_;
0054 
0055     double accumulatedCPUTime_;
0056   };
0057 }  // namespace edm
0058 
0059 #endif