User manual

UM0036 STice features
Doc ID 7705 Rev 11 281/385
4. Expand each code block in turn.
Expand successively the most time-consuming functions and instructions to determine
on which lines of code the most time is spent. Figure 214 shows how to expand the
main function to locate the ComputeOutputValue call. This call accounts for
approximately 91.12% of the processing time of the main function and 99.84% of the
processing time of line 70.
Figure 214. Bottleneck detection: top level
Figure 215 shows that when you expand the ComputeOutputValue function, the most
time-consuming instruction (highlighted in the illustration), is the one that computes the
result. By expanding this instruction, you can view the most time-consuming calls, shown in
Figure 216.
Figure 215. Bottleneck detection: intermediate level
5. Determine the cause of the bottleneck.
Examine the most time-consuming lines of code to determine whether you can fulfill the
same task with a more efficient structure or method. Thus, by successively zooming in
on the code down to the call level, you can identify very precisely the cause of a
bottleneck. In Figure 216, the most time-consuming calls are highlighted:
A call to a sinus function (CALL _sin)
A call to a float function (CALL c_fmul)
Therefore, an effective way of saving processing time, would be to replace the dynamic call
to the sinus function by a static table of computed sinus values, as shown in the code
example that follows. You could also decide to compute the result as an integer to avoid
calculating a float.