6 #ifndef TIMER_USE_STD_CLOCK
48 Timer (
bool startImmediately=
true) noexcept
50 isRunning_ = startImmediately;
58 storedLastElapsed_ = 0.0;
93 return storedLastElapsed_;
104 sumElapsed_ += storedLastElapsed_;
115 double storedLastElapsed_;
118 #ifdef TIMER_USE_STD_CLOCK
119 void rawReset() noexcept
121 cstart = std::clock();
124 double rawElapsed () const noexcept
126 return (std::clock()-cstart) /
static_cast<double>(CLOCKS_PER_SEC);
131 void rawReset() noexcept
133 cstart = std::chrono::high_resolution_clock::now();
136 double rawElapsed () const noexcept
138 std::chrono::high_resolution_clock::time_point now = std::chrono::high_resolution_clock::now();
139 std::chrono::duration<double> time_span = std::chrono::duration_cast<std::chrono::duration<double> >(now - cstart);
140 return time_span.count();
143 std::chrono::high_resolution_clock::time_point cstart;
Dune namespace.
Definition: alignedallocator.hh:11
A simple stop watch.
Definition: timer.hh:41
void reset() noexcept
Reset timer while keeping the running/stopped state.
Definition: timer.hh:55
double stop() noexcept
Stop the timer and return elapsed().
Definition: timer.hh:98
Timer(bool startImmediately=true) noexcept
A new timer, create and reset.
Definition: timer.hh:48
double elapsed() const noexcept
Get elapsed user-time from last reset until now/last stop in seconds.
Definition: timer.hh:75
double lastElapsed() const noexcept
Get elapsed user-time from last start until now/last stop in seconds.
Definition: timer.hh:86
void start() noexcept
Start the timer and continue measurement if it is not running. Otherwise do nothing.
Definition: timer.hh:64