Examine model for performance analysis
Examine the model f14
using the default
commandline settings.
model = 'f14';
res = solverprofiler.profileModel(model);
You can see a summary of the results by calling
res.summary
.
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 dialog to visualize them. This
step is equivalent to enabling OpenSP
when calling the
function.
solverprofiler.exploreResult(res)
Examine the model
ssc_actuator_custom_pneumatic
with a fully specified
configuration.
model = 'ssc_actuator_custom_pneumatic'; res = solverprofiler.profileModel(model, ... 'SaveStates' , 'on', ... 'SaveSimscapeStates' , 'On', ... 'SaveJacobian' , 'On', ... 'StartTime' , 5, ... 'StopTime' , 50, ... 'BufferSize', 10000,... 'TimeOut', 5,... 'OpenSP', 'On',... 'DataFullFile', fullfile(pwd, 'ssc_profiling_result.mat'));
model
— Model to examineName of model to be profiled, specified as a character vector.
Example: h =
solverprofiler.profileModel('vdp')
Specify optional
comma-separated pairs of Name,Value
arguments. Name
is
the argument name and Value
is the corresponding value.
Name
must appear inside quotes. You can specify several name and value
pair arguments in any order as
Name1,Value1,...,NameN,ValueN
.
'StartTime',0,'StopTime',10,'SaveStates','On'
'SaveStates'
— Save model states to fileBy 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 fileEnable this parameter to save Simscape states to a MAT-file.
Example: 'SaveSimscapeStates', 'On'
'SaveJacobian'
— Save model JacobianOption 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'
'StartTime'
— Profiler start timeTime, 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 timeTime, 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 loggingMaximum 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 resumeTime, 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 boxOption to open the Solver Profiler dialog box after profiling has completed.
Example: 'OpenSP','On'
'DataFullFile'
— Path and name of saved resultsBy 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'
res
— High-level summary of profiling resultsProfiling results, returned as a structure with the fields:
file
— Full path and name of saved resultsPath 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 resultsA 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