Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
roc::audio::Profiler Class Reference

Profiler The role of the profiler is to report the average processing speed (# of samples processed per time unit) during the last N seconds. We want to calculate the average processing speed efficiently (with O(1) complexity, without allocations, and as lightweight as possible). The problems with this are that we have variable-sized frames and SMA requires fixed-size chunks. To efficiently perform this calculation a ring buffer is employed. The idea behind the ring buffer is that each chunk of the buffer is the average speed of 10ms worth of samples. The ring buffer is initialized with fixed size (N * 1000)ms / (10ms) chunks. Within each chunk a weighted mean is used to calculate the average speed during those 10ms. Each frame will contribute a different number of samples to each chunk, the chunk speed is then weighted based on how many samples are contributed at what frame speed. As the chunks get populated the moving average is calculated. When the buffer is not entirely full the cumulative moving average algorithm is used and once the buffer is full the simple moving average algorithm is used. More...

#include <profiler.h>

Inheritance diagram for roc::audio::Profiler:
Collaboration diagram for roc::audio::Profiler:

Public Member Functions

 Profiler (core::IArena &arena, const audio::SampleSpec &sample_spec, ProfilerConfig profiler_config)
 Initialization. More...
 
bool is_valid () const
 Check if the profiler was succefully constructed. More...
 
void add_frame (size_t frame_size, core::nanoseconds_t elapsed)
 Profile frame speed. More...
 
float get_moving_avg ()
 Get computed average. More...
 

Detailed Description

Profiler The role of the profiler is to report the average processing speed (# of samples processed per time unit) during the last N seconds. We want to calculate the average processing speed efficiently (with O(1) complexity, without allocations, and as lightweight as possible). The problems with this are that we have variable-sized frames and SMA requires fixed-size chunks. To efficiently perform this calculation a ring buffer is employed. The idea behind the ring buffer is that each chunk of the buffer is the average speed of 10ms worth of samples. The ring buffer is initialized with fixed size (N * 1000)ms / (10ms) chunks. Within each chunk a weighted mean is used to calculate the average speed during those 10ms. Each frame will contribute a different number of samples to each chunk, the chunk speed is then weighted based on how many samples are contributed at what frame speed. As the chunks get populated the moving average is calculated. When the buffer is not entirely full the cumulative moving average algorithm is used and once the buffer is full the simple moving average algorithm is used.

Definition at line 65 of file profiler.h.

Constructor & Destructor Documentation

◆ Profiler()

roc::audio::Profiler::Profiler ( core::IArena arena,
const audio::SampleSpec sample_spec,
ProfilerConfig  profiler_config 
)

Initialization.

Member Function Documentation

◆ add_frame()

void roc::audio::Profiler::add_frame ( size_t  frame_size,
core::nanoseconds_t  elapsed 
)

Profile frame speed.

◆ get_moving_avg()

float roc::audio::Profiler::get_moving_avg ( )

Get computed average.

◆ is_valid()

bool roc::audio::Profiler::is_valid ( ) const

Check if the profiler was succefully constructed.


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