Changeset 425:4fbe868c1fb4 in lemon-0.x
- Timestamp:
- 04/26/04 19:33:51 (20 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@565
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/work/marci/time_measure.h
r327 r425 2 2 #ifndef HUGO_TIME_MEASURE_H 3 3 #define HUGO_TIME_MEASURE_H 4 5 ///ingroup graphs 6 ///\file 7 ///\brief Tools for measuring cpu usage 4 8 5 9 #include <sys/time.h> … … 11 15 namespace hugo { 12 16 13 // double currTime() { 14 // timeval tv; 15 // //timezone tz; 16 // gettimeofday(&tv, 0); 17 // return double(tv.tv_sec)+double(tv.tv_usec)/1000000.0; 18 // } 17 /// \addtogroup misc 18 /// @{ 19 19 20 /// Class to store (cpu)time instances.20 /// A class to store (cpu)time instances. 21 21 22 22 /// This class stores five time values. … … 28 28 /// 29 29 /// TimeStamp's can be added to or substracted from each other and 30 /// they can be push to a stream.30 /// they can be pushed to a stream. 31 31 32 32 class TimeStamp … … 39 39 tms &getTms() {return ts;} 40 40 const tms &getTms() const {return ts;} 41 double getRealTime() const {return real_time;} 42 ///Read the current time values of the process. 41 ///Read the current time values of the process 43 42 void stamp() 44 43 { … … 48 47 } 49 48 50 /// Constructor initializing with zero .49 /// Constructor initializing with zero 51 50 TimeStamp() 52 51 { ts.tms_utime=ts.tms_stime=ts.tms_cutime=ts.tms_cstime=0; real_time=0;} 53 ///Constructor initializing with the current time values of the process .52 ///Constructor initializing with the current time values of the process 54 53 TimeStamp(void *) { stamp();} 55 54 55 /// 56 56 TimeStamp &operator+=(const TimeStamp &b) 57 57 { … … 63 63 return *this; 64 64 } 65 /// 65 66 TimeStamp operator+(const TimeStamp &b) const 66 67 { … … 68 69 return t+=b; 69 70 } 71 /// 70 72 TimeStamp &operator-=(const TimeStamp &b) 71 73 { … … 77 79 return *this; 78 80 } 81 /// 79 82 TimeStamp operator-(const TimeStamp &b) const 80 83 { … … 92 95 friend std::ostream& operator<<(std::ostream& os,const TimeStamp &t); 93 96 97 ///Gives back the user time of the process 94 98 double getUserTime() const 95 99 { 96 100 return double(ts.tms_utime)/sysconf(_SC_CLK_TCK); 97 101 } 102 ///Gives back the system time of the process 98 103 double getSystemTime() const 99 104 { 100 105 return double(ts.tms_stime)/sysconf(_SC_CLK_TCK); 101 106 } 107 ///Gives back the user time of the process' children 102 108 double getCUserTime() const 103 109 { 104 110 return double(ts.tms_cutime)/sysconf(_SC_CLK_TCK); 105 111 } 112 ///Gives back the user time of the process' children 106 113 double getCSystemTime() const 107 114 { 108 115 return double(ts.tms_cstime)/sysconf(_SC_CLK_TCK); 109 116 } 117 ///Gives back the real time of the process 118 double getRealTime() const {return real_time;} 110 119 }; 111 120 112 ///Class measuring the cpu time and real time usage of the process .121 ///Class measuring the cpu time and real time usage of the process 113 122 class Timer 114 123 { … … 118 127 119 128 public: 120 ///Constructor. It starts with zero time counters .129 ///Constructor. It starts with zero time counters 121 130 Timer() {_reset();} 122 131 123 ///Computes the ellapsed time .132 ///Computes the ellapsed time 124 133 125 134 ///This conversion computes the ellapsed time … … 133 142 } 134 143 135 ///Resets the time counters .144 ///Resets the time counters 136 145 TimeStamp reset() 137 146 { … … 142 151 }; 143 152 144 ///Prints the time counters. 153 ///Prints the time counters 154 155 ///Prints the time counters in the folloing form: 156 /// 157 /// u: XX.XXs s: XX.XXs cu: XX.XXs cs: XX.XXs real: XX.XXs 158 /// 159 /// where the values are the 160 /// - a user cpu time, 161 /// - a system cpu time, 162 /// - a user cpu time of children, 163 /// - a system cpu time of children and 164 /// - a real time, 165 /// 166 ///respectively 145 167 inline std::ostream& operator<<(std::ostream& os,const TimeStamp &t) 146 168 { … … 154 176 } 155 177 178 /// @} 179 156 180 } //namespace hugo 157 181
Note: See TracChangeset
for help on using the changeset viewer.