Timer class. Starts counting when an object is instantiated, but can be reset via a call to start_timer(). Elapsed time is extracted simply by calling the object name as if it were a function (operator())
class Timer{
public:
Timer() { start=clock(); }
~Timer() {}
void start_timer() { start=clock(); }
double operator()() const
{
return (static_cast(clock()-start) /
static_cast(CLOCKS_PER_SEC));
}
private:
clock_t start;
};