6 #ifndef TIMER_USE_STD_CLOCK
61 isRunning_ = startImmediately;
69 storedLastElapsed_ = 0.0;
104 return storedLastElapsed_;
115 sumElapsed_ += storedLastElapsed_;
126 double storedLastElapsed_;
129 #ifdef TIMER_USE_STD_CLOCK
132 cstart = std::clock();
135 double rawElapsed ()
const throw (TimerError)
137 return (std::clock()-cstart) /
static_cast<double>(CLOCKS_PER_SEC);
142 void rawReset() throw (TimerError)
144 cstart = std::chrono::high_resolution_clock::now();
147 double rawElapsed ()
const throw (TimerError)
149 std::chrono::high_resolution_clock::time_point now = std::chrono::high_resolution_clock::now();
150 std::chrono::duration<double> time_span = std::chrono::duration_cast<std::chrono::duration<double> >(now - cstart);
151 return time_span.count();
154 std::chrono::high_resolution_clock::time_point cstart;
Timer(bool startImmediately=true)
A new timer, create and reset.
Definition: timer.hh:59
Exception thrown by the Timer class
Definition: timer.hh:33
A few common exception classes.
double elapsed() const
Get elapsed user-time from last reset until now/last stop in seconds.
Definition: timer.hh:86
Default exception class for OS errors.
Definition: exceptions.hh:269
void start()
Start the timer and continue measurement if it is not running. Otherwise do nothing.
Definition: timer.hh:75
A simple stop watch.
Definition: timer.hh:51
void reset()
Reset timer while keeping the running/stopped state.
Definition: timer.hh:66
double lastElapsed() const
Get elapsed user-time from last start until now/last stop in seconds.
Definition: timer.hh:97
double stop()
Stop the timer and return elapsed().
Definition: timer.hh:109