... | ... |
@@ -157,97 +157,97 @@ |
157 | 157 |
rtime/=b; |
158 | 158 |
return *this; |
159 | 159 |
} |
160 | 160 |
///\e |
161 | 161 |
TimeStamp operator/(double b) const |
162 | 162 |
{ |
163 | 163 |
TimeStamp t(*this); |
164 | 164 |
return t/=b; |
165 | 165 |
} |
166 | 166 |
///The time ellapsed since the last call of stamp() |
167 | 167 |
TimeStamp ellapsed() const |
168 | 168 |
{ |
169 | 169 |
TimeStamp t(NULL); |
170 | 170 |
return t-*this; |
171 | 171 |
} |
172 | 172 |
|
173 | 173 |
friend std::ostream& operator<<(std::ostream& os,const TimeStamp &t); |
174 | 174 |
|
175 | 175 |
///Gives back the user time of the process |
176 | 176 |
double userTime() const |
177 | 177 |
{ |
178 | 178 |
return utime; |
179 | 179 |
} |
180 | 180 |
///Gives back the system time of the process |
181 | 181 |
double systemTime() const |
182 | 182 |
{ |
183 | 183 |
return stime; |
184 | 184 |
} |
185 | 185 |
///Gives back the user time of the process' children |
186 | 186 |
|
187 | 187 |
///\note On <tt>WIN32</tt> platform this value is not calculated. |
188 | 188 |
/// |
189 | 189 |
double cUserTime() const |
190 | 190 |
{ |
191 | 191 |
return cutime; |
192 | 192 |
} |
193 | 193 |
///Gives back the user time of the process' children |
194 | 194 |
|
195 | 195 |
///\note On <tt>WIN32</tt> platform this value is not calculated. |
196 | 196 |
/// |
197 | 197 |
double cSystemTime() const |
198 | 198 |
{ |
199 | 199 |
return cstime; |
200 | 200 |
} |
201 | 201 |
///Gives back the real time |
202 | 202 |
double realTime() const {return rtime;} |
203 | 203 |
}; |
204 | 204 |
|
205 |
TimeStamp operator*(double b,const TimeStamp &t) |
|
205 |
inline TimeStamp operator*(double b,const TimeStamp &t) |
|
206 | 206 |
{ |
207 | 207 |
return t*b; |
208 | 208 |
} |
209 | 209 |
|
210 | 210 |
///Prints the time counters |
211 | 211 |
|
212 | 212 |
///Prints the time counters in the following form: |
213 | 213 |
/// |
214 | 214 |
/// <tt>u: XX.XXs s: XX.XXs cu: XX.XXs cs: XX.XXs real: XX.XXs</tt> |
215 | 215 |
/// |
216 | 216 |
/// where the values are the |
217 | 217 |
/// \li \c u: user cpu time, |
218 | 218 |
/// \li \c s: system cpu time, |
219 | 219 |
/// \li \c cu: user cpu time of children, |
220 | 220 |
/// \li \c cs: system cpu time of children, |
221 | 221 |
/// \li \c real: real time. |
222 | 222 |
/// \relates TimeStamp |
223 | 223 |
/// \note On <tt>WIN32</tt> platform the cummulative values are not |
224 | 224 |
/// calculated. |
225 | 225 |
inline std::ostream& operator<<(std::ostream& os,const TimeStamp &t) |
226 | 226 |
{ |
227 | 227 |
os << "u: " << t.userTime() << |
228 | 228 |
"s, s: " << t.systemTime() << |
229 | 229 |
"s, cu: " << t.cUserTime() << |
230 | 230 |
"s, cs: " << t.cSystemTime() << |
231 | 231 |
"s, real: " << t.realTime() << "s"; |
232 | 232 |
return os; |
233 | 233 |
} |
234 | 234 |
|
235 | 235 |
///Class for measuring the cpu time and real time usage of the process |
236 | 236 |
|
237 | 237 |
///Class for measuring the cpu time and real time usage of the process. |
238 | 238 |
///It is quite easy-to-use, here is a short example. |
239 | 239 |
///\code |
240 | 240 |
/// #include<lemon/time_measure.h> |
241 | 241 |
/// #include<iostream> |
242 | 242 |
/// |
243 | 243 |
/// int main() |
244 | 244 |
/// { |
245 | 245 |
/// |
246 | 246 |
/// ... |
247 | 247 |
/// |
248 | 248 |
/// Timer t; |
249 | 249 |
/// doSomething(); |
250 | 250 |
/// std::cout << t << '\n'; |
251 | 251 |
/// t.restart(); |
252 | 252 |
/// doSomethingElse(); |
253 | 253 |
/// std::cout << t << '\n'; |
0 comments (0 inline)