Skip to content

Commit d1f4e3b

Browse files
authored
Move stats API docs to config format
Replace enabling stats API with macros to using the official config system
1 parent 3391dcc commit d1f4e3b

File tree

1 file changed

+55
-7
lines changed

1 file changed

+55
-7
lines changed

docs/api/platform/MbedStats.md

Lines changed: 55 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,75 @@
11
## Mbed statistics
22

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 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+
```
414

515
### Memory statistics
616

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:
17+
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 enable the following Mbed OS configuration options.
818

9-
- `MBED_HEAP_STATS_ENABLED`.
10-
- `MBED_STACK_STATS_ENABLED`.
19+
```json
20+
{
21+
"target_overrides": {
22+
"*": {
23+
"platform.heap-stats-enabled": true,
24+
"platform.stack-stats-enabled": true
25+
}
26+
}
27+
}
28+
```
1129

1230
<span class="notes">**Note:** Each `malloc` or `calloc` memory allocation call adds an overhead of 8 bytes when heap memory statistics are enabled.</span>
1331

1432
### Thread statistics
1533

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.
34+
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.
35+
36+
```json
37+
{
38+
"target_overrides": {
39+
"*": {
40+
"platform.thread-stats-enabled": true,
41+
}
42+
}
43+
}
44+
```
1745

1846
### System information
1947

20-
You can use the `mbed_stats_sys_get` function to get the CPU ID and compiler information. You must build Mbed OS with the `MBED_SYS_STATS_ENABLED` macro to enable fetching of system information.
48+
You can use the `mbed_stats_sys_get` function to get the CPU ID and compiler information. To enable system information fetching, you must enable the following Mbed OS configuration option.
49+
50+
```json
51+
{
52+
"target_overrides": {
53+
"*": {
54+
"platform.sys-stats-enabled": true
55+
}
56+
}
57+
}
58+
```
2159

2260
### CPU statistics
2361

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.
62+
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. 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.
63+
64+
```json
65+
{
66+
"target_overrides": {
67+
"*": {
68+
"platform.cpu-stats-enabled": true
69+
}
70+
}
71+
}
72+
```
2573

2674
### Mbed statistics function reference
2775

0 commit comments

Comments
 (0)