Identify sources of simulation slowdowns
Use the Simulink® Profiler to examine model and block execution and identify issues that can contribute to poor simulation performance.
Open a model.
On the Debug tab, select Performance Advisor > Simulink Profiler.
On the Profile tab, click Profile.
When simulation is complete, the Profiler Report pane opens and displays the simulation profile for the model. You can share the results of the Profiling Run by exporting the report to HTML, as well as by saving the profiling data to a MAT file.
This example shows how to use the Simulink Profiler to track down the source of a simulation slowdown in your model.
This example uses a modified version of the
sldemo_fuelsys_dd model, (the Modeling a Fault-Tolerant Fuel Control System example) model with a slowdown artificially inserted.
Open the profiler for your model from the Debug tab by selecting Performance Advisor > Simulink Profiler.
Click Profile to profile the model. When simulation completes, the Profiler Report pane opens.
Observe that the Engine Gas Dynamics block takes a large portion of the total profiling time (177.759s out of 231.443s) of the top model. This is a useful place to start looking for the problematic block in the model.
Recursively expand the block hierarchy view. By default, the profiler sorts the blocks at the same level of the model in descending order of Total Time(s).
Observe that the For Iterator subsystem accounts for approximately 98% of the execution time of the EGO Sensor subsystem. It is highly probable that this is the source of the slow performance of the model.
Delete the block, reconnect the broken signal, and profile the model again. You should see significantly faster simulation times.
To compare the results between the two runs, click Add Report Panel and select the previous run from the Run list.
You can share the results of a selected run as an HTML report or as a MAT file. To share the profiler report, from the Share menu, select Generate Report for an HTML report or Export to save the results in a MAT file. The profiling results are exported to the current working folder in MATLAB™.
To view the generated report, you can open it in a supported web browser or use the built-in browser by passing the file path to the
web command. If you have MATLAB Report Generator™ installed, you can also use
rptview to view the report.