Main Content

sldiagnostics

Display diagnostic information about金宝appsystem

Syntax

sldiagnostics('sys')
[txtRpt, sRpt] = sldiagnostics('sys')
[txtRpt, sRpt] = sldiagnostics('sys',options)
[txtRpt, sRpt] = sldiagnostics('sys', 'CompileStats')
[txtRpt, sRpt] = sldiagnostics('sys', 'RTWBuildStats')

描述

sldiagnostics('sys')displays the following diagnostic information associated with the model or subsystem specified bysys:

  • Number of each type of block

  • Number of each type of Stateflow®object

  • Number of states, outputs, inputs, and sample times of the root model.

  • Names of libraries referenced and instances of the referenced blocks

  • Time and additional memory used for each compilation phase of the root model

If the model specified bysysis not loaded, thensldiagnosticsloads the model before performing the analysis.

The commandsldiagnostics('sys',options)displays only the diagnostic information associated with the specific operations listed asoptionscharacter vectors. The table below summarizes the options available and their corresponding valid input and output.

Withsldiagnostics, you can input the name of a model or the path to a subsystem. For some analysis options,sldiagnosticscan analyze only a root model. If you provide an incompatible input for one of these analyses, thensldiagnosticsissues a warning. Finally, if you input a Simulink®Library, thensldiagnosticscannot perform options that require a model compilation (Update Diagram). Instead,sldiagnosticsissues a warning.

During the analysis,sldiagnosticswill follow library links but will not follow or analyze Model References. Seefind_mdlrefsfor more information on finding allModelblocks and referenced models in a specified model.

Option

Valid Inputs

Output

CountBlocks

root model, library, or subsystem

Lists all unique blocks in the system and the number of occurrences of each. This includes blocks that are nested in masked subsystems or hidden blocks.

CountSF

root model, library, or subsystem

Lists all unique Stateflow objects in the system and the number of occurrences of each.

Sizes

root model

Lists the number of states, outputs, inputs, and sample times, as well as a flag indicating direct feedthrough, used in the root model.

Libs

root model, library, or subsystem

Lists all unique libraries referenced in the root model, as well as the names and numbers of the library blocks.

CompileStats

root model

Lists the time and additional memory used for each compilation phase of the root model. This information helps users troubleshoot model compilation speed and memory issues.

RTWBuildStats

root model

Lists the same information as theCompileStatsdiagnostic. When issued with the second output argumentsRpt, it captures the same statistics included inCompileStatsand also theSimulink Coder™build statistics.

You must explicitly specify this option, because it is not part of the default analysis.

All

not applicable

Performs all diagnostics.

Note

Running theCompileStatsdiagnostic before simulating a model for the first time will show greater memory usage. However, subsequent runs of theCompileStatsdiagnostic on the model will require less memory usage.

[txtRpt, sRpt] = sldiagnostics('sys')returns the diagnostic information as a textual reporttxtRptand a structure arraysRpt, which contains the following fields that correspond to the diagnostic options:

  • blocks

  • stateflow

  • sizes

  • links

  • compilestats

[txtRpt, sRpt] = sldiagnostics('sys',options)returns only the specified options. If your chosen options specify just one type of analysis, thensRptcontains the results of only that analysis.

[txtRpt, sRpt] = sldiagnostics('sys', 'CompileStats')returns information on time and memory usage intxtRptandsRpt.

[txtRpt, sRpt] = sldiagnostics('sys', 'RTWBuildStats')includesSimulink Coderbuild statistics in addition to the information reported forCompileStatsin thesRptoutput.

  • txtRptcontains the formatted textual output of time spent in each of the phases in Simulink andSimulink Coder(if you specifiedRTWBuildStats), for example:

    Compile Statistics For: rtwdemo_counter Cstat1: 0.00 seconds Model compilation pre-start Cstat2: 0.00 seconds Stateflow compile pre-start notification Cstat3: 0.10 seconds Post pre-comp-start engine event Cstat4: 10.00 seconds Stateflow compile start notification Cstat5: 0.00 seconds Model compilation startup completed

  • sRptis a MATLAB®structure containing time and memory usage for each of the phases, for example:

    sRpt = Model: 'myModel1' Statistics: [1x134 struct]
    The size of thesRpt.Statisticsarray indicates the number of compile and build phases executed during the operation. Examine the Statistics fields:
    sRpt.Statistics(1) = Description: 'Phase1' CPUTime: 7.2490 WallClockTime 4.0092 ProcessMemUsage: 26.2148 ProcessMemUsagePeak: 28.6680 ProcessVMSize: 15.9531
    CPUTimeandWallClockTimeshow the elapsed time for the phase in seconds.ProcessMemUsage,ProcessMemUsagePeakandProcessVMSizeshow the memory consumption during execution of the phase in MB.

Examine these key metrics to understand the performance:

  • WallClockTime—The real-time elapsed in each phase in seconds. Sum theWallClockTimein each phase to get the total time taken to perform the operation:

    ElapsedTime = sum([statRpt.Statistics(:).WallClockTime]);

  • ProcessMemUsage—The amount of memory consumed in each phase. Sum theProcessMemUsageacross all the phases to get the memory consumption during the entire operation:

    TotalMemory = sum([statRpt.Statistics(:).ProcessMemUsage]);

  • ProcessMemUsagePeak—The maximum amount of allocated memory in each phase. Get the maximum of this metric across all the phases to find the peak memory allocation during the operation:

    PeakMemory = max([statRpt.Statistics(:).ProcessMemUsagePeak]);

    Note

    可用内存统计信息只在微指令oft®Windows®platform.

Examples

The following command counts and lists each type of block used in thesldemo_bouncemodel that comes with Simulink software.

sldiagnostics('sldemo_bounce', 'CountBlocks')

The following command counts and lists both the unique blocks and Stateflow objects used in thesf_boilermodel that comes with Stateflow software; the textual report returned is captured asmyReport.

myReport = sldiagnostics('sf_boiler', 'CountBlocks', 'CountSF')

The following commands open thef14model that comes with Simulink software, and counts the number of blocks used in theControllersubsystem.

sldiagnostics('f14/Controller', 'CountBlocks')

The following command runs theSizesandCompileStatsdiagnostics on thef14model, capturing the results as both a textual report and structure array.

[txtRpt, sRpt] = sldiagnostics('f14', 'Sizes', 'CompileStats')
Introduced in R2006a