Bela
Real-time, ultra-low-latency audio and sensor processing system for BeagleBone Black
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
Classes | Functions
Computing CPU time

Classes

struct  BelaCpuData
 

Functions

int Bela_cpuMonitoringInit (int count)
 
BelaCpuDataBela_cpuMonitoringGet ()
 
void Bela_cpuTic (BelaCpuData *data)
 
void Bela_cpuToc (BelaCpuData *data)
 

Detailed Description

These functions allow to monitor CPU usage of the whole audio thread or of arbitrary sections of the program while it is running.

Manually calling Bela_cpuTic() and Bela_cpuToc() around specific sections of the code, the CPU performance of these sections can be evaluated. Calling these functions incurs an overhead.

When setting the internal CPU monitoring via Bela_cpuMonitoringInit(), the user can compute the CPU time of the entire audio thread. The core code internally calls Bela_cpuTic() and Bela_cpuToc() and the user can get the CPU usage details vai Bela_cpuMonitoringGet();

Note
These measurements are based on reading a monotonic clock and therefore they include not only actual CPU cycles consumed by the current thread but also any time the thread spends idle, either because it's blocked or because a higher priority thread is running.

Function Documentation

int Bela_cpuMonitoringInit ( int  count)

Set internal CPU monitoring for the audio thread.

Parameters
countNumber of samples (tic/toc pairs) in a acquisition cycle. Use 0 to disable.
Returns
0 on success, an error code otherwise.
BelaCpuData* Bela_cpuMonitoringGet ( )

Get stats about internal CPU monitoring.

Returns
a pointer to a BelaCpuData structure which contains data about the CPU usage of the audio thread.
void Bela_cpuTic ( BelaCpuData data)

Start measuring CPU time. When data->currentCount reaches data->count, a acquisition cycle is completed. data->percentage gives the average CPU busy time during the latest completed acquisition cycle.

Parameters
dataThe count field is an input and needs to be populated before calling. Other fields are used as I/O by the function.
void Bela_cpuToc ( BelaCpuData data)

Stop measuring CPU time.

Parameters
dataThe count field is an input and needs to be populated before calling. Other fields are used as I/O by the function.