Zth (libzth)
zth::EventRate< T, Bins, Count > Class Template Reference

Measure the rate of some event in Hz. More...

#include <perf.h>

Public Types

typedef T type
 
typedef Count count_type
 

Public Member Functions

 EventRate (type window=1) noexcept
 
void event (Timestamp const &now=Timestamp::now()) noexcept
 
void operator() (Timestamp const &now=Timestamp::now()) noexcept
 
type rate (Timestamp const &now=Timestamp::now()) const noexcept
 
 operator type () const noexcept
 

Detailed Description

template<typename T = float, size_t Bins = 2, typename Count = uint_fast32_t>
class zth::EventRate< T, Bins, Count >

Measure the rate of some event in Hz.

It counts events in bins, all with a contructor-provided (window) duration. When the count reaches about one per bin, there is significat jitter on the rate measurement. When the count is higher, the jitter is +/- 1 for a stable event rate.

The measurement is done regardless of the precision of clock_gettime(). It is fine to have events with 0 time in between.

Definition at line 491 of file perf.h.

Member Typedef Documentation

◆ count_type

template<typename T = float, size_t Bins = 2, typename Count = uint_fast32_t>
typedef Count zth::EventRate< T, Bins, Count >::count_type

Definition at line 495 of file perf.h.

◆ type

template<typename T = float, size_t Bins = 2, typename Count = uint_fast32_t>
typedef T zth::EventRate< T, Bins, Count >::type

Definition at line 494 of file perf.h.

Constructor & Destructor Documentation

◆ EventRate()

template<typename T = float, size_t Bins = 2, typename Count = uint_fast32_t>
zth::EventRate< T, Bins, Count >::EventRate ( type  window = 1)
inlineexplicitnoexcept

Definition at line 497 of file perf.h.

Member Function Documentation

◆ event()

template<typename T = float, size_t Bins = 2, typename Count = uint_fast32_t>
void zth::EventRate< T, Bins, Count >::event ( Timestamp const &  now = Timestamp::now())
inlinenoexcept

Definition at line 507 of file perf.h.

◆ operator type()

template<typename T = float, size_t Bins = 2, typename Count = uint_fast32_t>
zth::EventRate< T, Bins, Count >::operator type ( ) const
inlinenoexcept

Definition at line 555 of file perf.h.

◆ operator()()

template<typename T = float, size_t Bins = 2, typename Count = uint_fast32_t>
void zth::EventRate< T, Bins, Count >::operator() ( Timestamp const &  now = Timestamp::now())
inlinenoexcept

Definition at line 525 of file perf.h.

◆ rate()

template<typename T = float, size_t Bins = 2, typename Count = uint_fast32_t>
type zth::EventRate< T, Bins, Count >::rate ( Timestamp const &  now = Timestamp::now()) const
inlinenoexcept

Definition at line 530 of file perf.h.


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