26class concurrent_timer;
37 steady_clock_t::time_point stop_point{};
39 steady_clock_t::rep ticks{};
40 steady_clock_t::rep max{};
74 assert(stop_point >= start_point);
75 steady_clock_t::rep duration = (stop_point - start_point).count();
83 template <
typename timer_t>
85 void operator+=(timer_t
const & other)
87 steady_clock_t::rep ticks_to_add{};
89 ticks_to_add = other.ticks.load();
91 ticks_to_add = other.ticks;
93 ticks += ticks_to_add;
163 steady_clock_t::time_point stop_point{};
170 void update_max(steady_clock_t::rep
const value)
172 for (steady_clock_t::rep previous_value = max;
185 ticks{other.ticks.load()},
186 start_point{other.start_point},
187 stop_point{other.stop_point},
188 max{other.max.load()},
189 count{other.count.load()}
194 ticks = other.ticks.
load();
195 start_point = other.start_point;
196 stop_point = other.stop_point;
197 max = other.max.
load();
198 count = other.count.
load();
203 ticks{other.ticks.load()},
204 start_point{other.start_point},
205 stop_point{other.stop_point},
206 max{other.max.load()},
207 count{other.count.load()}
212 ticks = other.ticks.
load();
213 start_point = other.start_point;
214 stop_point = other.stop_point;
215 max = other.max.
load();
216 count = other.count.
load();
238 assert(stop_point >= start_point);
239 steady_clock_t::rep duration = (stop_point - start_point).count();
242 update_max(duration);
249 template <
typename timer_t>
251 void operator+=(timer_t
const & other)
253 ticks += other.ticks;
254 update_max(other.ticks);
277 assert(count.
load() > 0u);
A timer with a thread-safe operator+=().
Definition timer.hpp:156
void stop()
Stops the timer.
Definition timer.hpp:235
~concurrent_timer()=default
Defaulted.
double avg_in_seconds() const
Returns the average measured time interval in seconds.
Definition timer.hpp:275
constexpr bool operator==(serial_timer const &) const
Two timer are always equal.
Definition timer.hpp:285
constexpr bool operator==(concurrent_timer const &) const
Two timer are always equal.
Definition timer.hpp:291
concurrent_timer()=default
Defaulted.
double in_seconds() const
Returns the measured time in seconds.
Definition timer.hpp:263
concurrent_timer(concurrent_timer &&other) noexcept
Defaulted.
Definition timer.hpp:202
concurrent_timer & operator=(concurrent_timer &&other) noexcept
Defaulted.
Definition timer.hpp:210
concurrent_timer & operator=(concurrent_timer const &other)
Defaulted.
Definition timer.hpp:192
void start()
Starts the timer.
Definition timer.hpp:227
double max_in_seconds() const
Returns the maximum measured time interval in seconds.
Definition timer.hpp:269
concurrent_timer(concurrent_timer const &other)
Defaulted.
Definition timer.hpp:184
A timer.
Definition timer.hpp:32
constexpr bool operator==(serial_timer const &) const
Two timer are always equal.
Definition timer.hpp:139
serial_timer(serial_timer &&)=default
Defaulted.
double max_in_seconds() const
Returns the maximum measured time interval in seconds.
Definition timer.hpp:114
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:145
double avg_in_seconds() const
Returns the average measured time interval in seconds.
Definition timer.hpp:128
~serial_timer()=default
Defaulted.
void stop()
Stops the timer.
Definition timer.hpp:71
double in_seconds() const
Returns the measured time in seconds.
Definition timer.hpp:103
void start()
Starts the timer.
Definition timer.hpp:62
serial_timer(serial_timer const &)=default
Defaulted.
T compare_exchange_weak(T... args)