8#ifndef TIMER_USE_STD_CLOCK
50 Timer (
bool startImmediately=
true) noexcept
52 isRunning_ = startImmediately;
60 storedLastElapsed_ = 0.0;
95 return storedLastElapsed_;
106 sumElapsed_ += storedLastElapsed_;
117 double storedLastElapsed_;
120#ifdef TIMER_USE_STD_CLOCK
121 void rawReset() noexcept
123 cstart = std::clock();
126 double rawElapsed () const noexcept
128 return (std::clock()-cstart) /
static_cast<double>(CLOCKS_PER_SEC);
133 void rawReset() noexcept
135 cstart = std::chrono::high_resolution_clock::now();
138 double rawElapsed () const noexcept
140 std::chrono::high_resolution_clock::time_point now = std::chrono::high_resolution_clock::now();
141 std::chrono::duration<double> time_span = std::chrono::duration_cast<std::chrono::duration<double> >(now - cstart);
142 return time_span.count();
145 std::chrono::high_resolution_clock::time_point cstart;
Dune namespace.
Definition alignedallocator.hh:13
A simple stop watch.
Definition timer.hh:43
void reset() noexcept
Reset timer while keeping the running/stopped state.
Definition timer.hh:57
double stop() noexcept
Stop the timer and return elapsed().
Definition timer.hh:100
Timer(bool startImmediately=true) noexcept
A new timer, create and reset.
Definition timer.hh:50
double elapsed() const noexcept
Get elapsed user-time from last reset until now/last stop in seconds.
Definition timer.hh:77
double lastElapsed() const noexcept
Get elapsed user-time from last start until now/last stop in seconds.
Definition timer.hh:88
void start() noexcept
Start the timer and continue measurement if it is not running. Otherwise do nothing.
Definition timer.hh:66