The Code Profiling plugin displays:
- The number of calls to each function
- The percentage of time spent in each function
- The amount of time used by each function.
The percentage of time spent in each function and the number of calls to a function are reliably extracted. The user should not rely on the reported amount of time spent in each function as a definitive indicator of system performance. Code Profiling in a modestly "intrusive" process which prevents the precise timing information from being displayed. Code profling's intrusion however, can be measured and accounted for.
Code profiling is accomplished by "instrumenting" each function within the target code. This instrumentation process involves inserting a call at the beginning of each function that retrieves the PC and sends that data up through the debug tool to the IDE for time stamping and logging. Instrumentation also inserts a call at the end of each function that logs the corresponding function exit indicator. These calls add time to the function and may slow down system performance while profile data is being extracted. The amount of time added by these instrumentation calls depends upon the system clock speed, the MCU being used, and the compiler.
Timing with a Baseline Function
To determine the instrumented call overhead for a particular MCU/compiler/clock-speed the user will need to create and profile a baseline function. The baseline function is a function with little or no function overhead. A typical baseline function could be:
When profiled, the measured execution time for a baseline function is the overhead for the instrumented calls for the current speed of MCU and compiler. By subtracting this number from time spent in each function the user will get a clearer view of the amount of time spent in each function.
Caveats for Baseline Function Timing
If the application being tested uses clock-switching to alter the speed of the system clock during execution, care should be taken on relying on the baseline function as a true overhead indicator as some functions may operate at different clock frequencies.
If a function under consideration makes calls in turn to other sub-functions, the instrumented overhead for these sub-calls would not be included in a simple baseline extraction analysis. Further analysis would need to be performed.
Microchip Technology acquires Atmel