CVB++ 15.0
RateCounter Class Reference

Frame rate measurement counter with selectable averaging window. More...

#include <cvb/utilities/rate_counter.hpp>

Public Member Functions

 RateCounter ()
 Constructor for a rate counter object for multi-CPU architectures with default averaging window size (25). More...
 
 RateCounter (int windowSize)
 Constructor for a rate counter object for multi-CPU architectures. More...
 
 RateCounter (int windowSize, StopWatchMode mode)
 Constructor for a rate counter object. More...
 
StopWatchMode Mode () const noexcept
 The stop watch mode used internally. More...
 
int WindowSize () const noexcept
 Gets the currently used averaging window size. More...
 
void SetWindowSize (int windowSize)
 Sets the currently used averaging window size. More...
 
std::chrono::milliseconds AverageTimeSpan () const noexcept
 Average time span between two steps or since the creation of the counter or the most recent reset. More...
 
double Rate () const noexcept
 Returns the rate(1 / s) at which the steps occurred. More...
 
int NumSteps () const noexcept
 Number of steps called since construction or since last reset. More...
 
void Reset () noexcept
 Erase all measurements so far. More...
 
void Step () noexcept
 Reading step (first reading step will not yield a measurement result, but define the starting point). More...
 

Static Public Member Functions

static std::unique_ptr< RateCounterCreate ()
 Creates a frame counter object for multi CPU with default averaging window (25). More...
 
static std::unique_ptr< RateCounterCreate (int windowSize)
 Creates a frame counter object for multi CPU. More...
 
static std::unique_ptr< RateCounterCreate (int windowSize, StopWatchMode mode)
 Creates a frame counter object. More...
 

Static Public Attributes

static constexpr int MinimumWindowSize = 1
 Minimal selectable averaging window size.Trying to select a smaller window will result in an exception.
 
static constexpr int DefaultWindowSize = 25
 Default averaging window size.
 
static constexpr int MaximumWindowSize = 65535
 Maximum selectable averaging window size. Trying to select a larger window will result in an exception.
 

Detailed Description

Frame rate measurement counter with selectable averaging window.

Constructor & Destructor Documentation

◆ RateCounter() [1/3]

RateCounter ( )
inline

Constructor for a rate counter object for multi-CPU architectures with default averaging window size (25).

Exceptions
Anyexception derived from std::exception including CvbException.

◆ RateCounter() [2/3]

RateCounter ( int  windowSize)
inlineexplicit

Constructor for a rate counter object for multi-CPU architectures.

Parameters
[in]windowSizeAveraging window (i.e. number of measurements over which to average).
Exceptions
Anyexception derived from std::exception including CvbException.

◆ RateCounter() [3/3]

RateCounter ( int  windowSize,
StopWatchMode  mode 
)
inline

Constructor for a rate counter object.

Parameters
[in]windowSizeAveraging window (i.e. number of measurements over which to average).
[in]modeMode to use.
Exceptions
Anyexception derived from std::exception including CvbException.

Member Function Documentation

◆ AverageTimeSpan()

std::chrono::milliseconds AverageTimeSpan ( ) const
inlinenoexcept

Average time span between two steps or since the creation of the counter or the most recent reset.

Returns
The average time span or null if not enough measurements exist.
Exceptions
Doesnot throw any exception.

◆ Create() [1/3]

static std::unique_ptr< RateCounter > Create ( )
inlinestatic

Creates a frame counter object for multi CPU with default averaging window (25).

Returns
A pointer to a rate counter.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ Create() [2/3]

static std::unique_ptr< RateCounter > Create ( int  windowSize)
inlinestatic

Creates a frame counter object for multi CPU.

Parameters
[in]windowSizeAveraging window (i.e. number of measurements to be averaged over).
Returns
A pointer to a rate counter.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ Create() [3/3]

static std::unique_ptr< RateCounter > Create ( int  windowSize,
StopWatchMode  mode 
)
inlinestatic

Creates a frame counter object.

Parameters
[in]windowSizeAveraging window (i.e. number of measurements over which to average).
[in]modeMode to use.
Returns
A pointer to a rate counter.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ Mode()

StopWatchMode Mode ( ) const
inlinenoexcept

The stop watch mode used internally.

Returns
Mode of the rate counter.
Exceptions
Doesnot throw any exception.

◆ NumSteps()

int NumSteps ( ) const
inlinenoexcept

Number of steps called since construction or since last reset.

Returns
Number of steps.
Exceptions
Doesnot throw any exception.

◆ Rate()

double Rate ( ) const
inlinenoexcept

Returns the rate(1 / s) at which the steps occurred.

Returns
The rate(1/s) at which the steps
Exceptions
Doesnot throw any exception.

◆ Reset()

void Reset ( )
inlinenoexcept

Erase all measurements so far.

Exceptions
Doesnot throw any exception.

◆ SetWindowSize()

void SetWindowSize ( int  windowSize)
inline

Sets the currently used averaging window size.

Parameters
[in]windowSizebetween MinimumWindowSize and MaximumWindowSize.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ Step()

void Step ( )
inlinenoexcept

Reading step (first reading step will not yield a measurement result, but define the starting point).

Exceptions
Doesnot throw any exception.

◆ WindowSize()

int WindowSize ( ) const
inlinenoexcept

Gets the currently used averaging window size.

Returns
The window size.
Exceptions
Doesnot throw any exception.