Documentation

Execution Profiling for Real-Time Applications

This example shows how you can profile the task execution time and function execution time of your real-time application running on the target computer. Using that information, you can then tune its performance.

Profiling is especially useful if the real-time application is configured to take advantage of multicore processors on the target computer. To profile the real-time application:

  • In the Configuration Parameters for the model, enable the collection of function execution time data during execution.

  • Build, download, and execute the model.

  • Start and stop the profiler.

  • Display the profiler data.

Profiling slightly increases the execution time of the real-time application.

Configure Real-Time Application for Function Execution Profiling

In this section, the model is dxpcmds6t. To open this model, open the subsystem models first:

  1. Open model dxpcmds6t.

  2. In the top model, open the Configuration Parameters dialog box. Select Code Generation >> Verification.

  3. Select the Measure function execution times check box. The Measure task execution time check box is checked and locked.

4. Click OK. Save model dxpcmds6t in a local folder.

Generate Real-Time Application Execution Profile

In this section, generate profile data for model dxpcmds6t on a multicore target computer.

This procedure assumes that you have configured the target computer to take advantage of multiple cores. It also assumes that you previously configured the model for task and function execution profiling.

  1. Open, build, and download the model.

mdl = 'dxpcmds6t';
open_system(mdl);
rtwbuild(mdl);

When you include profiling, the Code Generation Report is generated by default. It contains links to the generated C code and include files. By clicking these links, you can examine the generated code and interpret the Code Execution Profile Report.

2. Start the profiler and then execute the real-time application.

tg = slrt;
startProfiler(tg);
start(tg);
pause(1)
stopProfiler(tg);
stop(tg);

3. Display the profiler data.

profiler_data = getProfilerData(tg)

The Execution Profile plot shows the allocation of execution cycles across the four processors, indicated by the colored horizontal bars.The model sections are listed in the Code Execution Profiling Report. The cores are indicated by the numbers underneath the bars.

The Code Execution Profiling Report displays model execution profile results for each task.

  • To display the profile data for a section of the model, in the Section column, click the Membrane button next to the task.

  • To display the TET data for the section in Simulation Data Inspector, click the Plot time series data button.

  • To view the section in Simulink Editor, click the link next to the Expand Tree button.

  • To view the lines of generated code corresponding to the section, click the Expand Tree button and then click the View Source button.

4. To investigate further improvements, see Improve Performance of Multirate Model.

Was this topic helpful?