STIR  6.2.0
Public Member Functions | List of all members
stir::TimedBlock< TimerT=Timer > Class Template Reference

Helper class for measuring execution time of a block of code.It starts the timer in ctor, stops in dtor. Do not create unnamed instances of this class, as they are quite useless: you cannot predict destruction time. More...

#include "stir/TimedBlock.h"

Public Member Functions

 TimedBlock (TimerT &Timer)
 Create a timed block.
 
virtual ~TimedBlock (void)
 Destroy a timed block.
 

Detailed Description

template<class TimerT>
class stir::TimedBlock< TimerT=Timer >

Helper class for measuring execution time of a block of code.

It starts the timer in ctor, stops in dtor. Do not create unnamed instances of this class, as they are quite useless: you cannot predict destruction time.

Usage:
SomeTimer t;
// do whatever you want here
{
TimedBlock<SomeTimer> tb(t);
do_something_1();
do_something_2();
};
// do whatever you want here
{
TimedBlock<SomeTimer> tb(t);
do_something_3();
};
// do whatever you want here
cout << "It took " << t.GetTime() << "sec to execute do_something_1..3()" << endl;
Template argument requirements

TimerT has to have a start() and stop() member function. This is the case for stir::Timer (and derived functions) and stir::HighResWallClockTimer.


The documentation for this class was generated from the following file: