Using Simulink | ![]() ![]() |
The Simulink simulation profiler collects performance data while simulating your model and generates a report, called a simulation profile, based on the data. The simulation profile generated by the profiler shows you how much time Simulink spends executing each function required to simulate your model. The profile enables you to determine the parts of your model that require the most time to simulate and hence where to focus your model optimization efforts.
Note You must have the Simulink Performance Tools option installed on your system to use the profiler. |
How the Profiler Works
The following pseudocode summarizes the execution model on which the profiler is based.
Sim() ModelInitialize(). ModelExecute() for t = tStart to tEnd Output() Update() Integrate() Compute states from derivs by repeatedly calling: MinorOutput() MinorDeriv() Locate any zero crossings by repeatedly calling: MinorOutput() MinorZeroCrossings() EndIntegrate Set time t = tNew. EndModelExecute ModelTerminate EndSim
According to this conceptual model, Simulink executes a Simulink model by invoking the following functions zero, one, or more times, depending on the function and the model.
Function |
Purpose |
Level |
sim |
Simulate the model. This top-level function invokes the other functions required to simulate the model. The time spent in this function is the total time required to simulate the model. |
System |
ModelInitialize |
Set up the model for simulation. |
System |
ModelExecute |
Execute the model by invoking the output, update, integrate, etc., functions for each block at each time step from the start to the end of simulation. |
System |
Output |
Compute the outputs of a block at the current time step. |
Block |
Update |
Update a block's state at the current time step. |
Block |
Integrate |
Compute a block's continuous states by integrating the state derivatives at the current time step. |
Block |
MinorOutput |
Compute a block's output at a minor time step. |
Block |
MinorDeriv |
Compute a block's state derivatives at a minor time step. |
Block |
MinorZeroCrossings |
Compute a block's zero-crossing values at a minor time step. |
Block |
ModelTerminate |
Free memory and perform any other end-of-simulation cleanup. |
System |
Nonvirtual Subsystem |
Compute the output of a nonvirtual subsystem (see Atomic Versus Virtual Subsystems) at the current time step by invoking the output, update, integrate, etc., functions for each block that it contains. The time spent in this function is the time required to execute the nonvirtual subsystem. |
Block |
The profiler measures the time required to execute each invocation of these functions and generates a report at the end of the model that describes how much time was spent in each function.
Enabling the Profiler
To profile a model, open the model and select Profiler from the Simulink Tools menu. Then start the simulation. When the simulation finishes, Simulink generates and displays the simulation profile for the model in the MATLAB help browser.
The Simulation Profile
Simulink stores the simulation profile in the MATLAB working directory.
The report has two sections: a summary and a detailed report.
Summary Section
The summary file displays the following performance totals.
The summary section then shows summary profiles for each function invoked to simulate the model. For each function listed, the summary profile specifies the following information.
Detailed Profile Section
This section contains detailed profiles for each function invoked to simulate the model. Each detailed profile contains all the information shown in the summary profile for the function. In addition, the detailed profile displays the function (parent function) that invoked the profiled function and the functions (child functions) invoked by the profiled function. Clicking the name of the parent or a child function takes you to the detailed profile for that function.
![]() | Merging Model Differences | Model Coverage Tool | ![]() |