69 TimeStamp() |
69 TimeStamp() |
70 { ts.tms_utime=ts.tms_stime=ts.tms_cutime=ts.tms_cstime=0; real_time=0;} |
70 { ts.tms_utime=ts.tms_stime=ts.tms_cutime=ts.tms_cstime=0; real_time=0;} |
71 ///Constructor initializing with the current time values of the process |
71 ///Constructor initializing with the current time values of the process |
72 TimeStamp(void *) { stamp();} |
72 TimeStamp(void *) { stamp();} |
73 |
73 |
74 /// |
74 ///\e |
75 TimeStamp &operator+=(const TimeStamp &b) |
75 TimeStamp &operator+=(const TimeStamp &b) |
76 { |
76 { |
77 ts.tms_utime+=b.ts.tms_utime; |
77 ts.tms_utime+=b.ts.tms_utime; |
78 ts.tms_stime+=b.ts.tms_stime; |
78 ts.tms_stime+=b.ts.tms_stime; |
79 ts.tms_cutime+=b.ts.tms_cutime; |
79 ts.tms_cutime+=b.ts.tms_cutime; |
80 ts.tms_cstime+=b.ts.tms_cstime; |
80 ts.tms_cstime+=b.ts.tms_cstime; |
81 real_time+=b.real_time; |
81 real_time+=b.real_time; |
82 return *this; |
82 return *this; |
83 } |
83 } |
84 /// |
84 ///\e |
85 TimeStamp operator+(const TimeStamp &b) const |
85 TimeStamp operator+(const TimeStamp &b) const |
86 { |
86 { |
87 TimeStamp t(*this); |
87 TimeStamp t(*this); |
88 return t+=b; |
88 return t+=b; |
89 } |
89 } |
90 /// |
90 ///\e |
91 TimeStamp &operator-=(const TimeStamp &b) |
91 TimeStamp &operator-=(const TimeStamp &b) |
92 { |
92 { |
93 ts.tms_utime-=b.ts.tms_utime; |
93 ts.tms_utime-=b.ts.tms_utime; |
94 ts.tms_stime-=b.ts.tms_stime; |
94 ts.tms_stime-=b.ts.tms_stime; |
95 ts.tms_cutime-=b.ts.tms_cutime; |
95 ts.tms_cutime-=b.ts.tms_cutime; |
96 ts.tms_cstime-=b.ts.tms_cstime; |
96 ts.tms_cstime-=b.ts.tms_cstime; |
97 real_time-=b.real_time; |
97 real_time-=b.real_time; |
98 return *this; |
98 return *this; |
99 } |
99 } |
100 /// |
100 ///\e |
101 TimeStamp operator-(const TimeStamp &b) const |
101 TimeStamp operator-(const TimeStamp &b) const |
102 { |
102 { |
103 TimeStamp t(*this); |
103 TimeStamp t(*this); |
104 return t-=b; |
104 return t-=b; |
105 } |
105 } |
106 |
|
107 ///The time ellapsed since the last call of stamp() |
106 ///The time ellapsed since the last call of stamp() |
108 TimeStamp ellapsed() const |
107 TimeStamp ellapsed() const |
109 { |
108 { |
110 TimeStamp t(NULL); |
109 TimeStamp t(NULL); |
111 return t-*this; |
110 return t-*this; |
178 ///Computes the ellapsed time |
177 ///Computes the ellapsed time |
179 |
178 |
180 ///This conversion computes the ellapsed time |
179 ///This conversion computes the ellapsed time |
181 ///since the construction of \c t or since |
180 ///since the construction of \c t or since |
182 ///the last \c t.reset(). |
181 ///the last \c t.reset(). |
183 operator TimeStamp () |
182 operator TimeStamp () const |
184 { |
183 { |
185 TimeStamp t; |
184 TimeStamp t; |
186 t.stamp(); |
185 t.stamp(); |
187 return t-start_time; |
186 return t-start_time; |
188 } |
187 } |
192 { |
191 { |
193 TimeStamp t(start_time); |
192 TimeStamp t(start_time); |
194 _reset(); |
193 _reset(); |
195 return start_time-t; |
194 return start_time-t; |
196 } |
195 } |
|
196 |
|
197 |
|
198 ///Gives back the ellapsed user time of the process |
|
199 double getUserTime() const |
|
200 { |
|
201 return operator TimeStamp().getUserTime(); |
|
202 } |
|
203 ///Gives back the ellapsed system time of the process |
|
204 double getSystemTime() const |
|
205 { |
|
206 return operator TimeStamp().getSystemTime(); |
|
207 } |
|
208 ///Gives back the ellapsed user time of the process' children |
|
209 double getCUserTime() const |
|
210 { |
|
211 return operator TimeStamp().getCUserTime(); |
|
212 } |
|
213 ///Gives back the ellapsed user time of the process' children |
|
214 double getCSystemTime() const |
|
215 { |
|
216 return operator TimeStamp().getCSystemTime(); |
|
217 } |
|
218 ///Gives back the ellapsed real time of the process |
|
219 double getRealTime() const |
|
220 { |
|
221 return operator TimeStamp().getRealTime(); |
|
222 } |
|
223 |
197 }; |
224 }; |
198 |
225 |
199 ///Prints the time counters |
226 ///Prints the time counters |
200 |
227 |
201 ///Prints the time counters in the following form: |
228 ///Prints the time counters in the following form: |