sldiagnostics
Display diagnostic information of Simulink system
Syntax
Description
sldiagnostics(
returns the
diagnostic information of a Simulink® model or subsystem in the Command Window with these statistics: modelName
)
Block Count — Names and counts of unique blocks
Stateflow® Count — Names and counts of unique Stateflow objects
Model Sizes — Counts of states, outputs, inputs, flags for direct feedthrough, and sample times
Library Usage Statistics — Names and counts of all the library blocks and referenced libraries
Compilation Statistics — Time and memory used to compile each phase
sldiagnostics(
returns the diagnostic information of a Simulink model or subsystem in the Command Window for the diagnostics listed in
modelName
,option1,...,optionN
)option1,...,optionN
. For example, using the option
CountBlocks
lists the names and counts of unique blocks in a
model or subsystem.
Examples
Report Diagnostic Information
Generate the diagnostic information of a Simulink model or subsystem and display it in the Command Window.
Open example BangBangControlUsingTemporalLogicExample
and generate diagnostic information of the root model
sf_boiler
.
openExample('stateflow/BangBangControlUsingTemporalLogicExample'); sldiagnostics('sf_boiler')
If you do not open or load the model, sldiagnostics
loads the model and generates the diagnostic information.
Report Specific Diagnostic Information
Generate specific diagnostic information of a Simulink model or subsystem and display it in the Command Window.
Open example BangBangControlUsingTemporalLogicExample
and generate diagnostic information related to the numbers of blocks and
Stateflow objects in the subsystem sf_boiler/Bang-Bang
Controller
.
openExample('stateflow/BangBangControlUsingTemporalLogicExample'); sldiagnostics('sf_boiler/Bang-Bang Controller','CountBlocks','countSF')
If you do not open or load the model, sldiagnostics
loads the model and generates the diagnostic information.
Report Diagnostic Information and Save Results
Generate diagnostic information of a model and save the results as formatted text and as a structure array.
Open example BangBangControlUsingTemporalLogicExample
and generate the diagnostic information of the root model
sf_boiler
. Save these reports in
myReport
and strucRpt
.
openExample('stateflow/BangBangControlUsingTemporalLogicExample'); [myReport,strucRpt] = sldiagnostics('sf_boiler');
If you do not open or load the model, sldiagnostics
loads the model and generates the diagnostic information.
Report Compile Time and Memory Statistics
Generate time and memory used by the model to compile and use this information to evaluate the performance of a model.
Compile Time and Memory Usage Data Collection
Load the model vdp
.
model = 'vdp';
load_system(model);
Generate the compile time diagnostic information of vdp
and store the results in txtRpt
and strucRpt
.
[txtRpt,strucRpt] = sldiagnostics(model,'CompileStats');
txtRpt
stores the compile time and description of each phase of vdp
as formatted text. sRpt
stores the compile time and memory used in each phase of vdp
as a structure.
strucRpt
strucRpt = struct with fields:
Model: 'vdp'
Statistics: [1×200 struct]
The size of the strucRpt.Statistics
array indicates the number of compile and build phases executed during compilation. Find the compile time and memory usage statistics for phase 20
.
strucRpt.Statistics(20)
ans = struct with fields:
Description: 'Finding and refreshing Model blocks'
CPUTime: 0
WallClockTime: 0.0010
ProcessMemUsage: 0.0430
ProcessMemUsagePeak: 0
ProcessVMSize: 0
The reported information includes:
CPUTime
Time in seconds the CPU takes to actively process a Simulink phase.
WallClockTime
The real-time elapsed in seconds to complete a single phase of the Simulink process. WallClockTime
is a sum of the CPUtime
, input-output time, and programming delays.
ProcessMemUsage
The working set size in megabytes used to execute a Simulink phase of operation. The working set size of a process is the amount of memory physically mapped to its process context.
ProcessMemUsagePeak
The peak working set size in megabytes used to execute a Simulink phase of operation.
ProcessVMSize
The amount of virtual memory or address space committed to the MATLAB™ process at the start of the phase of operation.
Performance Analysis of a Model
Use the following key metrics to analyze the performance of vdp
:
Total Elapsed Time Sum of the wall-clock time for each phase of
vdp
.Total Memory Sum of the memory used in each phase of
vdp
.Peak Memory The maximum memory used in a phase out of all phases of
vdp
.
ElapsedTime = sum([strucRpt.Statistics(:).WallClockTime])
ElapsedTime = 10.1960
TotalMemory = sum([strucRpt.Statistics(:).ProcessMemUsage])
TotalMemory = 153.1289
PeakMemory = max([strucRpt.Statistics(:).ProcessMemUsagePeak])
PeakMemory = 35.0273
Considerations
The
CompileStats
diagnostic option should be used when the model is loaded for the first time. Otherwise,sldiagnostics
reuses the previously compiled objects of the model and reports a lower time and memory usage for a model.Memory usage statistics are available only on the Microsoft® Windows® platform.
Input Arguments
modelName
— Name of Simulink model or path to subsystem
character vector | string
Name of a Simulink model or path to a subsystem to generate diagnostic information for, specified as a character vector or string.
Example: 'sf_boiler'
, 'sf_boiler/Bang-Bang
Controller'
Data Types: char
| string
option1,...,optionN
— Diagnostic option
character vector | string
Diagnostic options that represents specific sets of diagnostic information, specified as a character vector or string. Some diagnostic options work only with root models. The table lists the diagnostic options, compatible input system types, and expected output.
Diagnostic Option | Input System Type | Output |
---|---|---|
| root model, library, or subsystem | Names and counts of unique blocks used in the system. This includes blocks that are nested in masked subsystems or are hidden. |
| root model, library, or subsystem | Names and counts of unique Stateflow objects used in the system. |
| root model | Counts of states, outputs, inputs, flags for direct feedthrough, and sample times used in the model. |
| root model, library, or subsystem | Names and counts of all library blocks and unique libraries referenced in the system. |
| root model | Time and memory used to compile each phase of the model. This information helps users troubleshoot model compilation speed and memory issues. |
| root model | Simulink
Coder™ build statistics and all statistics
returned when using the
You must explicitly specify this option, because it is not a part of the default analysis. |
| root model | All diagnostics, including those provided by
|
sldiagnostics
issues a warning when:
The diagnostic option and input system type are incompatible.
The input system type is a Simulink library. For such systems,
sldiagnostics
cannot generate diagnostics for options that require a model compilation, such as Update Diagram.
Example: 'CountBlocks'
Data Types: char
| string
Output Arguments
txtRpt
— Diagnostic report
character vector
Diagnostic report that stores the diagnostic information of the Simulink system as a formatted text, returned as a character vector.
sRpt
— Diagnostic report
structure array
Diagnostic report that stores the diagnostic information of the Simulink system, returned as a structure array. The structure array has these fields corresponding to the diagnostic options:
blocks
stateflow
sizes
links
compilestats
rtwbuildstats
Data Types: struct
Version History
Introduced in R2006a
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)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)