Main Content

How Simulink Profiler Captures Performance Data

How Simulink Profiler Works

The Simulink Profiler captures performance data while your model simulates. It identifies the parts of your model that require the most time to simulate. Use the profiling information to decide where to focus your model optimization efforts.


The Simulink Profiler does not support rapid accelerator simulation.

Simulink® stores performance data in the simulation profile report. The data shows the time spent executing each function in your model.

The basis for the Simulink Profiler is an execution model that this pseudocode summarizes.

		for t = tStart to tEnd
			Compute states from derivs by repeatedly calling: 
			Locate any zero crossings by repeatedly calling: 
		Set time t = tNew. 

According to this conceptual model, Simulink runs a model by invoking the following functions zero, one, or many times, depending on the function and the model.


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.



Set up the model for simulation.



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.



Compute the outputs of a block at the current time step.



Update the state of a block at the current time step.



Compute the continuous states of a block by integrating the state derivatives at the current time step.



Compute block output at a minor time step.



Compute the state derivatives of a block at a minor time step.



Compute zero-crossing values of a block at a minor time step.



Free memory and perform any other end-of-simulation cleanup.


Nonvirtual Subsystem

Compute the output of a nonvirtual subsystem 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.


The Simulink Profiler measures the time required to execute each invocation of these functions. After the model simulates, the Simulink Profiler generates a report that describes the amount of simulation time spent on each function.

Start Profiler

  1. Open the model.

  2. In the Simulink Editor, on the Debug tab, click the Performance button arrow and select Simulink Profiler.

    The Debug tab of the Simulink Toolstrip has the Performance list expanded with the pointer paused on the Simulink Profiler option.

  3. Run a profiling simulation. On the Profile tab that opens, click Profile.

When simulation is complete, the Simulink Profiler generates and displays the simulation profile for the model in a panel in the Simulink Editor.

The Simulink Editor is open for the model sldemo_antiwindup with the Profile tab selected. Two Profiler Report panes are open at the bottom of the Simulink Editor. Each pane displays results from a different profiling simulation run using the Simulink Profiler.

Block Hierarchy View

The block hierarchy view of the report presents the profiling information of the model in a nested tree form. The first row of the table—which is the top of the tree—corresponds to the entire model. Subsequent rows at the first level of nesting correspond to blocks at the root level of the model.

The block hierarchy view in the Profiler Report pane.

Execution Stack view

The execution stack view breaks down the profiling report by simulation phase of the model. The main simulation phases of a model are compilation, initialization, simulation, and termination. For a more detailed explanation of simulation phases, see Simulation Phases in Dynamic Systems.

The execution stack view in the Profiler Report pane.

Save Profiler Results

You can save the Profiler report to a mat file. At a later time, you can import and review the report by either loading the saved mat file to the current workspace or import it into an existing profiler session.

To save a profiling report, select Export to MAT in the Share section of the Profile tab and optionally specify a name for the mat file.

To view a saved report in an open profiling session in the Simulink editor, select Import from File in the Profile tab.

To view a saved report in the command line, load the MAT-file that contains the report. The profiling information is loaded into the current workspace as a Simulink.profiler.Data object.

Related Topics