HIBF 1.0.0-rc.1
All Classes Namespaces Files Functions Variables Typedefs Friends Macros Modules Pages Concepts
seqan::hibf::concurrent_timer Class Reference

A timer with a thread-safe operator+=(). More...

#include <hibf/misc/timer.hpp>

Public Member Functions

Constructors, destructor and assignment
 concurrent_timer ()=default
 Defaulted.
 
 concurrent_timer (concurrent_timer const &other)
 Defaulted.
 
concurrent_timeroperator= (concurrent_timer const &other)
 Defaulted.
 
 concurrent_timer (concurrent_timer &&other) noexcept
 Defaulted.
 
concurrent_timeroperator= (concurrent_timer &&other) noexcept
 Defaulted.
 
 ~concurrent_timer ()=default
 Defaulted.
 
Modification
void start ()
 Starts the timer.
 
void stop ()
 Stops the timer.
 
template<typename timer_t >
requires (std::same_as<timer_t, serial_timer> || std::same_as<timer_t, concurrent_timer>)
void operator+= (timer_t const &other)
 Adds another timer.
 
Access
double in_seconds () const
 Returns the measured time in seconds.
 
double max_in_seconds () const
 Returns the maximum measured time interval in seconds.
 
double avg_in_seconds () const
 Returns the average measured time interval in seconds.
 
Comparison
constexpr bool operator== (serial_timer const &) const
 Two timer are always equal.
 
constexpr bool operator== (concurrent_timer const &) const
 Two timer are always equal.
 

Friends

class serial_timer
 

Detailed Description

A timer with a thread-safe operator+=().

Member Function Documentation

◆ start()

void seqan::hibf::concurrent_timer::start ( )
inline

Starts the timer.

◆ stop()

void seqan::hibf::concurrent_timer::stop ( )
inline

Stops the timer.

In Debug mode, an assertion checks that start() has been called before.

Attention
This function is not thread-safe.

◆ operator+=()

template<typename timer_t >
requires (std::same_as<timer_t, serial_timer> || std::same_as<timer_t, concurrent_timer>)
void seqan::hibf::concurrent_timer::operator+= ( timer_t const & other)
inline

Adds another timer.

This function is thread-safe.

◆ in_seconds()

double seqan::hibf::concurrent_timer::in_seconds ( ) const
inline

Returns the measured time in seconds.

◆ max_in_seconds()

double seqan::hibf::concurrent_timer::max_in_seconds ( ) const
inline

Returns the maximum measured time interval in seconds.

A time interval may be:

◆ avg_in_seconds()

double seqan::hibf::concurrent_timer::avg_in_seconds ( ) const
inline

Returns the average measured time interval in seconds.

A time interval may be:

The count used for averaging is the number of calls to stop() and operator+=().

Warning
Calling this function when neither stop() or operator+=() have been used is undefined behaviour.

◆ operator==() [1/2]

constexpr bool seqan::hibf::concurrent_timer::operator== ( serial_timer const & ) const
inlineconstexpr

Two timer are always equal.

◆ operator==() [2/2]

constexpr bool seqan::hibf::concurrent_timer::operator== ( concurrent_timer const & ) const
inlineconstexpr

Two timer are always equal.


The documentation for this class was generated from the following file: