|
1 | 1 | ## Mbed statistics
|
2 | 2 |
|
3 |
| -Mbed OS provides a set of functions that you can use to capture the memory and thread statistics at runtime. `mbed_stats.h` declares these functions. To enable all Mbed OS statistics, you must build code with the `MBED_ALL_STATS_ENABLED` macro. |
| 3 | +Mbed OS provides a set of functions that you can use to capture the memory and thread statistics at runtime. `mbed_stats.h` declares these functions. To enable all Mbed OS platform statistics, you must enable the following Mbed OS configuration option: |
| 4 | + |
| 5 | +```json |
| 6 | +{ |
| 7 | + "target_overrides": { |
| 8 | + "*": { |
| 9 | + "platform.all-stats-enabled": true |
| 10 | + } |
| 11 | + } |
| 12 | +} |
| 13 | +``` |
| 14 | + |
| 15 | +<span class="tips">**Tip:** See the documentation of the [Arm Mbed configuration system](../reference/configuration.html) for more details about `mbed_app.json`. </span> |
4 | 16 |
|
5 | 17 | ### Memory statistics
|
6 | 18 |
|
7 |
| -You can use memory statistics functions to capture heap usage, cumulative stack usage or stack usage per thread at runtime. To enable memory usage monitoring, you must build Mbed OS with the following macros: |
| 19 | +You can use memory statistics functions to capture heap use, cumulative stack use or stack use for each thread at runtime. To enable memory use monitoring, you must enable the following Mbed OS configuration options: |
8 | 20 |
|
9 |
| -- `MBED_HEAP_STATS_ENABLED`. |
10 |
| -- `MBED_STACK_STATS_ENABLED`. |
| 21 | +```json |
| 22 | +{ |
| 23 | + "target_overrides": { |
| 24 | + "*": { |
| 25 | + "platform.heap-stats-enabled": true, |
| 26 | + "platform.stack-stats-enabled": true |
| 27 | + } |
| 28 | + } |
| 29 | +} |
| 30 | +``` |
11 | 31 |
|
12 | 32 | <span class="notes">**Note:** Each `malloc` or `calloc` memory allocation call adds an overhead of 8 bytes when heap memory statistics are enabled.</span>
|
13 | 33 |
|
14 | 34 | ### Thread statistics
|
15 | 35 |
|
16 |
| -You can use the thread statistics function `mbed_stats_thread_get_each` to capture the thread ID, state, priority, name and stack information for all active threads at runtime. To enable thread monitoring, you must build Mbed OS with the `MBED_THREAD_STATS_ENABLED` macro. |
| 36 | +You can use the thread statistics function `mbed_stats_thread_get_each` to capture the thread ID, state, priority, name and stack information for all active threads at runtime. To enable thread monitoring, you must enable the following Mbed OS configuration options: |
| 37 | + |
| 38 | +```json |
| 39 | +{ |
| 40 | + "target_overrides": { |
| 41 | + "*": { |
| 42 | + "platform.thread-stats-enabled": true |
| 43 | + } |
| 44 | + } |
| 45 | +} |
| 46 | +``` |
17 | 47 |
|
18 | 48 | ### System information
|
19 | 49 |
|
20 |
| -You can use the `mbed_stats_sys_get` function to get the CPU ID, compiler information and RAM and ROM memories on the target device. You must build Mbed OS with the `MBED_SYS_STATS_ENABLED` macro to enable fetching of system information. |
| 50 | +You can use the `mbed_stats_sys_get` function to get the CPU ID, compiler information and RAM and ROM memories on the target device. To enable system information fetching, you must enable the following Mbed OS configuration option: |
| 51 | + |
| 52 | +```json |
| 53 | +{ |
| 54 | + "target_overrides": { |
| 55 | + "*": { |
| 56 | + "platform.sys-stats-enabled": true |
| 57 | + } |
| 58 | + } |
| 59 | +} |
| 60 | +``` |
21 | 61 |
|
22 | 62 | ### CPU statistics
|
23 | 63 |
|
24 |
| -You can use the `mbed_stats_cpu_get` function to get the uptime, idle time and sleep time information. Timing information available is cumulative since the system is on. You must build Mbed OS with the `MBED_CPU_STATS_ENABLED` macro to enable fetching of CPU information. Please note CPU statistics depend on the availability of the low power timer in the hardware. |
| 64 | +You can use the `mbed_stats_cpu_get` function to get the uptime, idle time and sleep time information. Timing information available is cumulative because the system is on. Please note CPU statistics depend on the availability of the low power timer in the hardware. To enable fetching of CPU information, you must enable the following Mbed OS configuration option: |
| 65 | + |
| 66 | +```json |
| 67 | +{ |
| 68 | + "target_overrides": { |
| 69 | + "*": { |
| 70 | + "platform.cpu-stats-enabled": true |
| 71 | + } |
| 72 | + } |
| 73 | +} |
| 74 | +``` |
25 | 75 |
|
26 | 76 | ### Mbed statistics function reference
|
27 | 77 |
|
|
0 commit comments