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 profile data during execution.
Build, download, and execute the model.
profile_slrt to collect and
display the profile data.
Profiling slightly increases the execution time of the real-time application.
This example shows how to configure model
task execution profiling.
In the top model, open the Configuration Parameters dialog box, and select Code Generation > Verification.
Select the Measure task execution time check box.
Task execution time (TET) measures how long it takes the kernel to run for one base-rate time step. For a multirate model, use the profiler to find out what the execution time is for each rate.
If you also want to profile function execution times, select the Measure function execution times check box.
Under Code Generation, select Simulink Real-Time Options.
Type a value for Number of profiling events (each uses 20 bytes).
By default, the software logs 5000 events for profiling. You
can increase or decrease this number to manage memory usage. When
the software logs the specified number of events or the model stops,
the software stops collecting the data. The software writes the data
the target computer.
This example shows how to generate profile
data for model
dxpcmds6t using default settings
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.
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.
Execute the real-time application.
tg = slrt; start(tg) pause(2) stop(tg)
Profile the real-time application execution.
profileInfo.modelname = 'dxpcmds6t.mdl'; profData = profile_slrt(profileInfo);
The Execution Profile plot shows the allocation of execution cycles across the four processors, indicated by the colored horizontal bars.
The Code Execution Profiling Report displays model execution profile results for each task.
|Maximum turnaround time||Longest time between start and end of code section, which includes preemption time.|
|Average turnaround time||Average time between start and end of code section, which includes preemption time.|
|Maximum execution time||Longest time between start and end of code section, which excludes preemption time.|
|Average execution time||Average time between start and end of code section, which excludes preemption time.|
|Calls||Number of calls to the code section.|
To display the profile data for the generated code section, click the Membrane button in the Coder Execution Profiling Report.
Close the model.