1.. _cpu_load:
2
3CPU load
4########
5
6Module can be used to track how much time is spent in idle. It is using tracing hooks
7which are called before and after CPU goes to idle. Compared to :ref:`thread_analyzer`
8it is more accurate since it takes into account time spent in the interrupt context as well.
9
10Function :c:func:`cpu_load_get` is used to get the latest value. It is also used to reset
11the measurement. By default, module is using :c:func:`k_cycle_get_32` but in cases when higher
12precision is needed a :ref:`counter_api` device can be used.
13
14Load can also be reported periodically using a logging message. Period is configured using :kconfig:option:`CONFIG_CPU_LOAD_LOG_PERIODICALLY`.
15
16Using counter device
17********************
18
19In order to use :ref:`counter_api` device :kconfig:option:`CONFIG_CPU_LOAD_USE_COUNTER` must be
20enabled and chosen in devicetree must be set.
21
22.. code-block:: devicetree
23
24   chosen {
25     zephyr,cpu-load-counter = &counter_device;
26   };
27