identify solver performance bottlenecks -凯发k8网页登录
identify solver performance bottlenecks
description
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.
more
available actions
trace
configure
explore
information panes
statistics
step size
suggestions
open the solver profiler
simulink® toolstrip: on the debug tab, in the performance section, click performance advisor , then select solver profiler.
solver information menu: to open the solver information menu, click the hyperlink on the right of the status bar at the bottom of the simulink editor. then, click solver profiler .
examples
identify source of zero crossing event
use the solver profiler to locate the source of zero crossings that occur in simulation for a model of a bouncing ball.
open the model bouncingballwithswitch
.
open the solver profiler. in the simulink™ toolstrip, on the debug tab, in the performance section, click the performance advisor button arrow. then, select solver profiler.
in the solver profiler, click run. the solver profiler simulates the model and collects information about solver events that occur. when the simulation completes, the solver profiler displays information in the statistics pane and a plot of the step size calculated for each step of the simulation.
in the statistics pane, scroll down to view the event information, which shows that 45 zero-crossing events occurred during simulation from one source.
to view information about the source of the zero-crossing events, select the zero crossing tab. the zero crossing events come from the switch block.
to annotate the plot of the step sizes with the zero-crossing events, in the statistics pane, click the value for the total zero crossings row. the yellow dots indicate when each zero crossing occurred. where the zero crossings occurred, the step size decreased significantly.
to highlight in the block diagram the switch block that produced the zero crossings, in the zero crossing tab, select the block path. then, in the states explorer toolstrip, in the trace section, click highlight block.
related examples
parameters
from
— 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.
to
— 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
.
buffer
— 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.
continuous states
— 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 the profiler data mat file.
if you select this parameter, it will enable the states explorer.
simscape states
— save simscape™ states to file
off (default) | on
enable this parameter to save simscape states to the profiler data mat file.
if you select this parameter, it will enable the simscape explorer.
zero crossing
— save zero crossing data to file
off (default) | on
enable this parameter to save zero crossing information to the profiler data mat file
if you select this parameter, it will enable the zero-crossing explorer.
model jacobian
— 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 .
for a more detailed explanation of the solver jacobian, see .
simscape stiffness
— log stiffness analysis of simscape states
array
log stiffness analysis simscape states, specified as an array. this parameter provides an array of time points that you want to log the simscape stiffness states to the profiler data mat file. enable this parameter to show simscape stiffness tab in the suggestion pane.
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 physical system concepts, see (simscape)
rule customization
— change thresholds for profiler rules
off (default) | on
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.'; else diagnosticsstring{1} = 'zero-crossing events detected.'; end end
profilerdata
. this array of structures organizes all the
information that the solver profiler collects during a profiling run. it contains the
following substructures.
substructure | fields |
---|---|
stateinfo : stores information on block
states |
|
blockinfo : cross-reference of blocks and state
ids |
|
zcsrcinfo : stores information on blocks causing zero
crossing events |
|
zcevents : cross-reference of the time stamps of zero
crossing events and the corresponding state ids |
|
exceptionevents : cross-reference of exception event
timestamps, the id of the corresponding state that caused the event, and the
cause. |
|
resettime : stores timestamps of solver
resets. | none |
tout : stores simulation times. | none |
solver exception
— show solver exception events
off (default) | on
enable this parameter to highlight solver exception events in the step size plot of the solver profiler.
solver reset
— show solver reset events
off (default) | on
enable this parameter to highlight solver reset events in the step size plot of the solver profiler.
jacobian update
— show jacobian update events
off (default) | on
enable this parameter to highlight jacobian update events in the step size plot of the solver profiler.
zero crossing
— show zero crossing events
off (default) | on
enable this parameter to highlight zero crossing events in the step size plot of the solver profiler.
version history
introduced in r2016a
see also
| |
打开示例
您曾对此示例进行过修改。是否要打开带有您的编辑的示例?
matlab 命令
您点击的链接对应于以下 matlab 命令:
请在 matlab 命令行窗口中直接输入以执行命令。web 浏览器不支持 matlab 命令。
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
- (español)
- (english)
- (english)
europe
- (english)
- (english)
- (deutsch)
- (español)
- (english)
- (français)
- (english)
- (italiano)
- (english)
- (english)
- (english)
- (deutsch)
- (english)
- (english)
- switzerland
- (english)
asia pacific
- (english)
- (english)
- (english)
- 中国
- (日本語)
- (한국어)