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
Extra/cpu-monitoring/render.cpp

Monitor the CPU usage of your code

We use Bela_cpuMonitoringSet() and Bela_cpuMonitoringGet() to measure the CPU usage of the entire audio thread. This is roughly equivalent to the CPU usage as reported by the IDE.We also use Bela_cpuToc() and Bela_cpuTic() to measure the CPU usage of a specific portion of code. We generate a white noise signal and filter it through a lowpass filter and we want to measure the CPU usage of the noise generation part only. We write the the code in such a way that the noise signal for all frames is computed first and only then the filter is applied to all frames, so that Bela_cpuTic() and Bela_cpuToc() are called only once per block, minimising overhead and increasing the accuracy of the measured time.

From a separate thread we print the CPU usage of the entire audio thread and of the noise generator.