equal
deleted
inserted
replaced
309 Timer(bool run=true) :_running(run) {_reset();} |
309 Timer(bool run=true) :_running(run) {_reset();} |
310 |
310 |
311 ///\name Control the state of the timer |
311 ///\name Control the state of the timer |
312 ///Basically a Timer can be either running or stopped, |
312 ///Basically a Timer can be either running or stopped, |
313 ///but it provides a bit finer control on the execution. |
313 ///but it provides a bit finer control on the execution. |
314 ///The \ref Timer also counts the number of \ref start() |
314 ///The \ref lemon::Timer "Timer" also counts the number of |
315 ///executions, and is stops only after the same amount (or more) |
315 ///\ref lemon::Timer::start() "start()" executions, and it stops |
316 ///\ref stop() "stop()"s. This can be useful e.g. to compute |
316 ///only after the same amount (or more) \ref lemon::Timer::stop() |
317 ///the running time |
317 ///"stop()"s. This can be useful e.g. to compute the running time |
318 ///of recursive functions. |
318 ///of recursive functions. |
319 /// |
|
320 |
319 |
321 ///@{ |
320 ///@{ |
322 |
321 |
323 ///Reset and stop the time counters |
322 ///Reset and stop the time counters |
324 |
323 |
470 |
469 |
471 |
470 |
472 ///@} |
471 ///@} |
473 }; |
472 }; |
474 |
473 |
475 ///Same as \ref Timer but prints a report on destruction. |
474 ///Same as Timer but prints a report on destruction. |
476 |
475 |
477 ///Same as \ref Timer but prints a report on destruction. |
476 ///Same as \ref Timer but prints a report on destruction. |
478 ///This example shows its usage. |
477 ///This example shows its usage. |
479 ///\code |
478 ///\code |
480 /// void myAlg(ListGraph &g,int n) |
479 /// void myAlg(ListGraph &g,int n) |
489 class TimeReport : public Timer |
488 class TimeReport : public Timer |
490 { |
489 { |
491 std::string _title; |
490 std::string _title; |
492 std::ostream &_os; |
491 std::ostream &_os; |
493 public: |
492 public: |
494 ///\e |
493 ///Constructor |
495 |
494 |
|
495 ///Constructor. |
496 ///\param title This text will be printed before the ellapsed time. |
496 ///\param title This text will be printed before the ellapsed time. |
497 ///\param os The stream to print the report to. |
497 ///\param os The stream to print the report to. |
498 ///\param run Sets whether the timer should start immediately. |
498 ///\param run Sets whether the timer should start immediately. |
499 |
|
500 TimeReport(std::string title,std::ostream &os=std::cerr,bool run=true) |
499 TimeReport(std::string title,std::ostream &os=std::cerr,bool run=true) |
501 : Timer(run), _title(title), _os(os){} |
500 : Timer(run), _title(title), _os(os){} |
502 ///\e Prints the ellapsed time on destruction. |
501 ///Destructor that prints the ellapsed time |
503 ~TimeReport() |
502 ~TimeReport() |
504 { |
503 { |
505 _os << _title << *this << std::endl; |
504 _os << _title << *this << std::endl; |
506 } |
505 } |
507 }; |
506 }; |
508 |
507 |
509 ///'Do nothing' version of \ref TimeReport |
508 ///'Do nothing' version of TimeReport |
510 |
509 |
511 ///\sa TimeReport |
510 ///\sa TimeReport |
512 /// |
511 /// |
513 class NoTimeReport |
512 class NoTimeReport |
514 { |
513 { |