25class concurrent_timer;
36 steady_clock_t::time_point stop_point{};
38 steady_clock_t::rep ticks{};
39 steady_clock_t::rep max{};
73 assert(stop_point >= start_point);
74 steady_clock_t::rep duration = (stop_point - start_point).count();
82 template <
typename timer_t>
84 void operator+=(timer_t
const & other)
86 steady_clock_t::rep ticks_to_add{};
88 ticks_to_add = other.ticks.load();
90 ticks_to_add = other.ticks;
92 ticks += ticks_to_add;
84 void operator+=(timer_t
const & other) {
…}
162 steady_clock_t::time_point stop_point{};
169 void update_max(steady_clock_t::rep
const value)
171 for (steady_clock_t::rep previous_value = max;
184 ticks{other.ticks.load()},
185 start_point{other.start_point},
186 stop_point{other.stop_point},
187 max{other.max.load()},
188 count{other.count.load()}
193 ticks = other.ticks.
load();
194 start_point = other.start_point;
195 stop_point = other.stop_point;
196 max = other.max.
load();
197 count = other.count.
load();
202 ticks{other.ticks.load()},
203 start_point{other.start_point},
204 stop_point{other.stop_point},
205 max{other.max.load()},
206 count{other.count.load()}
211 ticks = other.ticks.
load();
212 start_point = other.start_point;
213 stop_point = other.stop_point;
214 max = other.max.
load();
215 count = other.count.
load();
237 assert(stop_point >= start_point);
238 steady_clock_t::rep duration = (stop_point - start_point).count();
241 update_max(duration);
248 template <
typename timer_t>
250 void operator+=(timer_t
const & other)
252 ticks += other.ticks;
253 update_max(other.ticks);
250 void operator+=(timer_t
const & other) {
…}
276 assert(count.
load() > 0u);
A timer with a thread-safe operator+=().
Definition timer.hpp:155
void stop()
Stops the timer.
Definition timer.hpp:234
~concurrent_timer()=default
Defaulted.
double avg_in_seconds() const
Returns the average measured time interval in seconds.
Definition timer.hpp:274
constexpr bool operator==(serial_timer const &) const
Two timer are always equal.
Definition timer.hpp:284
constexpr bool operator==(concurrent_timer const &) const
Two timer are always equal.
Definition timer.hpp:290
concurrent_timer()=default
Defaulted.
double in_seconds() const
Returns the measured time in seconds.
Definition timer.hpp:262
concurrent_timer(concurrent_timer &&other) noexcept
Defaulted.
Definition timer.hpp:201
concurrent_timer & operator=(concurrent_timer &&other) noexcept
Defaulted.
Definition timer.hpp:209
concurrent_timer & operator=(concurrent_timer const &other)
Defaulted.
Definition timer.hpp:191
void start()
Starts the timer.
Definition timer.hpp:226
double max_in_seconds() const
Returns the maximum measured time interval in seconds.
Definition timer.hpp:268
concurrent_timer(concurrent_timer const &other)
Defaulted.
Definition timer.hpp:183
A timer.
Definition timer.hpp:31
constexpr bool operator==(serial_timer const &) const
Two timer are always equal.
Definition timer.hpp:138
serial_timer(serial_timer &&)=default
Defaulted.
double max_in_seconds() const
Returns the maximum measured time interval in seconds.
Definition timer.hpp:113
serial_timer()=default
Defaulted.
serial_timer & operator=(serial_timer &&)=default
Defaulted.
serial_timer & operator=(serial_timer const &)=default
Defaulted.
constexpr bool operator==(concurrent_timer const &) const
Two timer are always equal.
Definition timer.hpp:144
double avg_in_seconds() const
Returns the average measured time interval in seconds.
Definition timer.hpp:127
~serial_timer()=default
Defaulted.
void stop()
Stops the timer.
Definition timer.hpp:70
double in_seconds() const
Returns the measured time in seconds.
Definition timer.hpp:102
void start()
Starts the timer.
Definition timer.hpp:61
serial_timer(serial_timer const &)=default
Defaulted.
T compare_exchange_weak(T... args)