CPU measurement module
Use the CPU measurement module to monitor CPU load.
Module events
Source Module |
Input Event |
This Module |
Output Event |
Sink Module |
|---|---|---|---|---|
|
|
|||
|
None |
|||
|
Note
See the Application overview for more information about the event-based communication in the nRF Desktop application and about how to read this table.
Configuration
To enable this module, use the CONFIG_DESKTOP_CPU_MEAS_ENABLE Kconfig option.
This option selects the CONFIG_NRF_CPU_LOAD Kconfig option, which enables the CPU load measurement library that is used to perform the measurements.
Set the time between subsequent CPU load measurements, in milliseconds, using the CONFIG_DESKTOP_CPU_MEAS_PERIOD option.
Measurement results
The module can provide the measurement results in the following ways:
CONFIG_DESKTOP_CPU_MEAS_RESULT_NRF_PROFILER- The module uses the nRF Profiler API directly to emit the CPU load. This minimizes the impact of providing the results on the measured CPU load. The option depends on theCONFIG_NRF_PROFILERKconfig option and is enabled by default if the nRF Profiler is enabled.CONFIG_DESKTOP_CPU_MEAS_RESULT_EVENT- The module submits the CPU load as acpu_load_event. The option selects theCONFIG_DESKTOP_CPU_LOAD_EVENTKconfig option, which enables the event. The option is enabled by default unless theCONFIG_DESKTOP_CPU_MEAS_RESULT_NRF_PROFILERoption is enabled.
You must enable at least one of these options. You can enable both options at the same time.
Implementation details
The module periodically reads the CPU load, provides the result, and resets the measurement. If reading the CPU load fails, the module reports an error state and stops the measurements.
The CPU load is presented in 0.001% units. Depending on the configuration, the result is provided in the following ways:
Through the nRF Profiler event - The module registers the
cpu_loadnRF Profiler event type with a singleloadfield. The event is emitted only if profiling of the event is enabled.Through the application event - The
cpu_load_event.loadpresents the CPU load. The event can be displayed in the logs or using the nRF Profiler.