solverprofiler.profileModel
Examine model for performance analysis using the Solver Profiler programmatic interface
Description
Examples
Examine a Model with Default Settings
Examine the model f14
using the default
settings.
model = 'f14';
res = solverprofiler.profileModel(model);
Inspect the summary of the results.
res.summary
struct with fields: solver: 'ode45' tStart: 0 tStop: 60 absTol: 1.0000e-06 relTol: 1.0000e-04 hMax: 0.1000 hAverage: 0.0444 steps: 1352 profileTime: 0.9974 zcNumber: 0 resetNumber: 600 jacobianNumber: 0 exceptionNumber: 195
Open the results in the Solver Profiler to visualize them. This step is
equivalent to enabling OpenSP
when calling the
function.
solverprofiler.exploreResult(res)
Configure Solver Profiler and Examine a Model
Examine the model
ssc_actuator_custom_pneumatic
with a fully specified
configuration.
model = 'ssc_actuator_custom_pneumatic'; res = solverprofiler.profileModel(model, ... 'SaveStates' , 'On', ... 'SaveZCSignals', 'On',... 'SaveSimscapeStates' , 'On', ... 'SaveJacobian' , 'On', ... 'StartTime' , 5, ... 'StopTime' , 50, ... 'BufferSize', 10000,... 'TimeOut', 5,... 'OpenSP', 'On',... 'DataFullFile', fullfile(pwd, 'ssc_profiling_result.mat'));
Input Arguments
model
— Name of model to profile
string | character vector
Name of model to profile, specified as a string or a character vector.
Example: h =
solverprofiler.profileModel('vdp')
Name-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN
, where Name
is
the argument name and Value
is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Before R2021a, use commas to separate each name and value, and enclose
Name
in quotes.
Example: 'StartTime',0,'StopTime',10,'SaveStates','On'
SaveStates
— Save model states to file
off (default) | on
By default, the profiler does not save the states of the model. Enabling this parameter configures the profiler to save the states to a MAT-file.
Example: 'SaveStates','On'
SaveSimscapeStates
— Save Simscape™ states to file
off (default) | on
Enable this parameter to save Simscape states to a MAT-file.
Example: 'SaveSimscapeStates', 'On'
SaveJacobian
— Save model Jacobian
off (default) | on
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.
Example: 'SaveJacobian', 'On'
SaveZCSignals
— Save zero-crossing signal to MAT file
off (default) | on
Option to save the zero-crossing signal to a MAT file, specified as
either 'off'
or 'on'
.
Example: 'SaveZCSignals', 'On'
StartTime
— Profiler start time
model start time (default) | scalar
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.
Example: 'StartTime',5
StopTime
— Profiler stop time
model stop time (default) | scalar
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
.
Example: 'StopTime',30
BufferSize
— Memory impact of logging
50000 (default) | positive scalar
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.
Example: 'BufferSize',60000
TimeOut
— Maximum time to wait for solver to resume
positive scalar
Time, in seconds, to wait before the profiler stops running. This option is useful in situations where the simulation is unable to proceed. The profiler waits for the specified time and quits if no progress has been made.
Example: 'TimeOut', 10
OpenSP
— Open the Solver Profiler dialog box
off (default) | on
Option to open the Solver Profiler dialog box after profiling has completed.
Example: 'OpenSP','On'
DataFullFile
— Path and name of saved results
character vector of full file path
By default, the profiling results are saved in a MAT-file named
model_@_dd_Month_yyyy_hh_mm_ss.mat
in the current
working folder. You can specify a different file name by which to save
the results in the current working folder. To save the file in a
different location, specify the full path of the file, including the
file name.
Example: 'DataFullFile','C:\Users\myusername\Documents\profiled\vdp_results.mat'
Output Arguments
res
— High-level summary of profiling results
structure
Profiling results, returned as a structure with the fields:
file
— Full path and name of saved results
character vector
Path and name of the MAT-file where the results of the
profiling operation are stored as MAT file. By default, they are
stored in the current working folder with a file name having the
pattern: model_@_dd_Month_yyyy_hh_mm_ss.mat
.
To store them in a different location or by a different name,
specify DataFullFile
when calling
solverprofiler.profileModel
.
summary
— Summary of profiling results
structure
A high-level summary of the results of the profiling operation, returned as a structure. The summary provides an overview of the performance of the simulation and health of the model.
The summary
structure contains these
fields.
Field | Purpose | Values | Description |
---|---|---|---|
solver | Solver used by simulation | any of the solvers supported by Solver Profiler | Solver used by the simulation as configured in the Configuration Parameters for the model. For a list of all the solvers, see Solver. The Solver Profiler does not support models without any continuous states. |
tStart | Start time of simulation | scalar | Start time, in seconds, for the simulation of the model during the profiling operation. |
tStop | Stop time of simulation | scalar | Stop time, in seconds, of the simulation
during the profiling operation. If
StopTime is set to be earlier
than the configured Stop Time of the model, the
simulation stops at
StopTime . |
absTol | Absolute tolerance of the solver | positive scalar | Absolute tolerance of the solver as specified in the configuration settings for the model. For more information, see Absolute tolerance |
relTol | Relative tolerance of the solver | positive scalar | Relative tolerance of the solver as specified in the configuration settings of the model. For more information, see Relative tolerance |
hMax | Maximum step size | positive scalar | Largest time step that the solver can take. See Max step size. |
hAverage | Average step size | positive scalar | Average size of the time step taken by the solver. |
steps | Total steps taken | positive scalar | Total number of time steps taken by the solver. |
profileTime | Time to profile | positive scalar | Time, in seconds, taken by the Solver Profiler to examine the model. |
zcNumber | Total number of zero crossings | nonnegative scalar | Number of times zero crossings occur during the simulation of the model. The detection of these zero crossings incurs computational cost and can slow down the simulation. For information on zero-crossing detection, see Zero-Crossing Detection. |
resetNumber | Number of solver resets | nonnegative scalar | Number of times the solver has to reset its parameters. |
jacobianNumber | Number of Jacobian updates | nonnegative scalar | Number of times the solver Jacobian matrix is updated during a simulation. For more information, see Explicit Versus Implicit Continuous Solvers. |
exceptionNumber | Number of solver exceptions | nonnegative scalar | Total number of solver exceptions encountered during a simulation. These exceptions are events where the solver is unable to solve the model states to the specified accuracy. As a result, the solver runs adjusted trials which increase computational cost. |
Data Types: struct
Version History
Introduced in R2017b
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)