Profiling
Running code on the target and profiling is the best way to ensure the Worst-Case Execution Time (WCET) for critical functionality and make necessary optimizations if needed.
The challenge with profiling is that it is an intrusive operation, as the code source needs to be modified or instrumented to enable traces that can tell us more about what is happening internally on the target.
Profiling depends on target capabilities. Some cores have integrated units for tracing, as we saw in the previous chapter, providing profiling that is minimally invasive. Also, some targets have special interfaces that allow high-speed trace data transfer using advanced debugging and tracing probes connected to the host machine. We can see an example of profiling infrastructure used for some Cortex-M targets in the following figure:

Figure 3.10 – Arm target connected to host machine over a debug probe
In Figure 3.10, we can see an Arm target connected over a debugging...