CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
LinuxCPUTime.h
Go to the documentation of this file.
1 #ifndef UTILITIES_TIMING_LINUXCPUTIME_H
2 #define UTILITIES_TIMING_LINUXCPUTIME_H
3 //
4 // V 0.0
5 //
6 
7 
8 #include <iosfwd>
9 #include <string>
10 #include <fstream>
11 #include "ctime"
13 
16 class LinuxCPUTime {
17 public:
18 
19  typedef double TimeType;
20 
21 
23  explicit LinuxCPUTime(int pid=0):
24  utime_(std::clock()/CLOCKS_PER_SEC), stime_(0) {
25  }
26 
29 
31  inline TimeType utime() const { return utime_;}
32  inline TimeType stime() const { return stime_;}
33  inline TimeType cputime() const { return utime_+stime_;}
34  inline TimeType operator()() const { return cputime();}
35 
36 private:
39 };
40 
42 public:
43  static std::ostream * dout;
44  LinuxElapsedTime(const std::string & iname="Total",
45  std::ostream & iout=*dout) : out(iout), name(iname){}
47 
48 private:
49  std::ostream & out;
50  std::string name;
52 };
53 
54 
55 struct LCPUTime {
56 
57  struct OneTick {
58  OneTick() : one(0.01) {}
59 
60  double one;
61  };
62 
63  static double oneTick() {
64  static OneTick local;
65  return local.one;
66  };
67 
68 
72 
73  inline static TimeType time() { LinuxCPUTime a; return a();}
74  inline static TimeType time(int pid) { LinuxCPUTime a(pid); return a();}
75 
76 };
77 
79 
80 
81 #endif // UTILITIES_TIMING_LINUXCPUTIME_H
TimeType stime() const
Definition: LinuxCPUTime.h:32
LinuxCPUTime begin
Definition: LinuxCPUTime.h:51
static double oneTick()
Definition: LinuxCPUTime.h:63
std::string name
Definition: LinuxCPUTime.h:50
TimeType cputime() const
Definition: LinuxCPUTime.h:33
TimeType operator()() const
Definition: LinuxCPUTime.h:34
TimeType utime_
Definition: LinuxCPUTime.h:37
TimeType stime_
Definition: LinuxCPUTime.h:38
static std::ostream * dout
Definition: LinuxCPUTime.h:43
static TimeType time()
Definition: LinuxCPUTime.h:73
static TimeType time(int pid)
Definition: LinuxCPUTime.h:74
GenTimer< LCPUTime > LinuxCPUTimer
Definition: LinuxCPUTime.h:78
double TimeType
Definition: LinuxCPUTime.h:19
LinuxCPUTime(int pid=0)
constructor
Definition: LinuxCPUTime.h:23
std::ostream & out
Definition: LinuxCPUTime.h:49
GenTimeInterval< LCPUTime > TimeInterval
Definition: LinuxCPUTime.h:66
double a
Definition: hdecay.h:121
LinuxElapsedTime(const std::string &iname="Total", std::ostream &iout=*dout)
Definition: LinuxCPUTime.h:44
LinuxCPUTime::TimeType TimeType
Definition: LinuxCPUTime.h:71
TimeType utime() const
Definition: LinuxCPUTime.h:31
LinuxCPUTime::TimeType IntervalType
Definition: LinuxCPUTime.h:70
~LinuxCPUTime()
destructor
Definition: LinuxCPUTime.h:28