Main Content

Solver Profiler

Identify solver performance bottlenecks


Use the Solver Profiler to examine solver and model behavior to identify issues that can contribute to poor simulation performance.

Use the Solver Profiler to analyze a model for patterns that affect its simulation. The Solver Profiler presents graphical and statistical information about the simulation, solver settings, events, and errors. You can use this data to identify locations in the model that caused simulation bottlenecks.

In addition, there are multiple factors that can limit the simulation speed. The Solver Profiler logs and reports all the major events that occur when simulating a model:

  • Zero-crossing events

  • Solver exception events

  • Solver reset events

  • Jacobian computation events

These events are common and necessary for an accurate simulation. However, they do incur computational cost and frequent occurrences can slow down or even stall the simulation.

Available actions

  • Trace

  • Filter

  • Explore

Information Panes

  • Statistics

  • Step Size

  • Suggestions

Open the Solver Profiler

Open the Solver Profiler by clicking the hyperlink in the lower-right corner of the Simulink® Editor.


expand all

This example shows how to find the source of a particular solver event using a model that simulates a ball bouncing off the ground. As the ball comes to rest, the density of zero-crossings increase, leading to a solver slowdown.

To begin, open the ex_spi_show_zc model and launch the Solver Profiler.

Click Run to profile the model.

Notice that the model has 45 zero-crossing events, Select the Zero Crossing tab in the Results pane.

Select the ex_spi_show_zc/Switch field in the Results pane. All zero crossing events caused by the Switch block are highlighted in the Step Size plot.

In the Trace section of the toolstrip, select Highlight Block.

You should see the Switch block causing the zero crossing events.

Related Examples



By default, the profiler does not save the states of the model. Enabling this parameter configures the profiler to save the states to the profiler data MAT file.

Enable this parameter to save Simscape states to the profiler data MAT file.

Enable this parameter to save zero crossing information to the profiler data MAT file

Option to log the solver Jacobian matrices to memory. This option is useful for simulations that use implicit solvers. For a comparison of solvers, see Compare Solvers.

For a more detailed explanation of the solver Jacobian, see Choose a Jacobian Method for an Implicit Solver.

Enable this parameter to log the stiffness analysis of Simscape states to the profiler data MAT file. For more information on Simscape representation of stiffness and other phsyical system concepts, see How Simscape Models Represent Physical Systems (Simscape)

Time, in seconds, of the simulation that the profiler starts analyzing the model. This is not the same as the start time of the simulation.

Time, in seconds, of the simulation to which the profiler should profile the model. By default, the analysis continues until the end of the simulation. Changing this parameter does not change the stop time of the model which you specify in the Model Configuration Parameters.

A value less than the configured stop time of the model stops the profiling and simulation at StopTime.

Maximum number of events that are logged. If the number of logged events reaches this value and memory is available, increase BufferSize. If memory is limited, consider lowering the value.


Enable this parameter to highlight solver exception events in the Step Size plot of the Solver Profiler.

Enable this parameter to highlight solver reset events in the Step Size plot of the Solver Profiler.

Enable this parameter to highlight zero crossing events in the Step Size plot of the Solver Profiler.

Enable this parameter to highlight Jacobian update events in the Step Size plot of the Solver Profiler.

Click Rule Customization in the Solver Profiler to access the rule set. You can change the thresholds for most of these rules and also select which rules you want to apply selectively during a simulation run.

To modify a rule, enable its customization and then enter a desired threshold value.

Custom Rule Set

You can override the settings on the Rule Set dialog box by specifying a custom rule set.

Create a rule set as a MATLAB® script and specify the path to the script in the Custom Rule Set section of the Rule Set dialog box.

A simple rule set example looks as follows:

function diagnosticsString = customRule(profilerData)
		if isempty(profilerData.zcEvents)
			diagnosticsString{1} = 'No zero crossing event detected.';
			diagnosticsString{1} = 'Zero-crossing events detected.';
The input to the function is an array of structures called profilerData. This array of structures organizes all the information that the Solver Profiler collects during a profiling run. It contains the following substructures.

stateInfo: Stores information on block states
  • name: Block name

  • value: State values

  • blockIdx: Block ID

blockInfo: Cross-reference of blocks and state IDs
  • name: Block name

  • stateIdx: State ID

zcSrcInfo: Stores information on blocks causing zero crossing events
  • name: Block name

  • blockIdx: Block ID

zcEvents: Cross-reference of the time stamps of zero crossing events and the corresponding state IDs
  • t: Event timestamp

  • srcIdx: Block ID

exceptionEvents: Cross-reference of exception event timestamps, the ID of the corresponding state that caused the event, and the cause.
  • t: Event timestamp

  • stateIdx: State ID

  • cause: Cause of exception

resetTime: Stores timestamps of solver resets.None
tout: Stores simulation times.None

Data Types: double

More About

expand all

Introduced in R2016a