sldiagnostics
R2026bDisplay 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
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.
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.
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.
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
Open example BangBangControlUsingTemporalLogicExample
and generate the compile time diagnostic information of the root model
sf_boiler. Store the results in
txtRpt and strucRpt.
openExample('stateflow/BangBangControlUsingTemporalLogicExample'); [txtRpt,strucRpt] = sldiagnostics(sf_boiler,'CompileStats');
txtRpt stores the compile time and description of each
phase of sf_boiler as formatted text.
strucRpt stores the compile time and memory used in
each phase of sf_boiler as a structure.
strucRpt
strucRpt =
struct with fields:
Model: 'sf_boiler'
Statistics: [1×197 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
6.
strucRpt.Statistics(6)
ans =
struct with fields:
Description: 'Stateflow compile pre-start notification'
CPUTime: 0
WallClockTime: 0.2222
ProcessMemUsage: 0.7852
ProcessMemUsagePeak: 0
ProcessVMSize: 1.0781The 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.WallClockTimeis a sum of theCPUTime, 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
sf_boiler:
Total Elapsed Time — Sum of the wall-clock time for each phase of
sf_boiler.Total Memory — Sum of the memory used in each phase of
sf_boiler.Peak Memory — The maximum memory used in a phase out of all phases of
sf_boiler.
ElapsedTime = sum([strucRpt.Statistics(:).WallClockTime])
ElapsedTime = 17.5542
TotalMemory = sum([strucRpt.Statistics(:).ProcessMemUsage])
TotalMemory = 98.1602
PeakMemory = max([strucRpt.Statistics(:).ProcessMemUsagePeak])
PeakMemory = 75.1016
Considerations
The
CompileStatsdiagnostic option should be used when the model is loaded for the first time. Otherwise,sldiagnosticsreuses 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
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
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. |
'CountBlocksInRefs' | root model, library, or subsystem | Names and counts of unique blocks used in system and its references. |
| 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,
sldiagnosticscannot generate diagnostics for options that require a model compilation, such as Update Diagram.
Example: 'CountBlocks'
Data Types: char | string
Output Arguments
Diagnostic report that stores the diagnostic information of the Simulink system as a formatted text, returned as a character vector.
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:
blocksstateflowsizeslinkscompilestatsrtwbuildstats
Data Types: struct
Version History
Introduced in R2006aYou can now count all blocks used in a system and its references using the
CountBlocksInRefs argument.
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.
Sélectionner un site web
Choisissez un site web pour accéder au contenu traduit dans votre langue (lorsqu'il est disponible) et voir les événements et les offres locales. D’après votre position, nous vous recommandons de sélectionner la région suivante : .
Vous pouvez également sélectionner un site web dans la liste suivante :
Comment optimiser les performances du site
Pour optimiser les performances du site, sélectionnez la région Chine (en chinois ou en anglais). Les sites de MathWorks pour les autres pays ne sont pas optimisés pour les visites provenant de votre région.
Amériques
- 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)