Stateflow Halstead Difficulty Distribution
Metric ID
slcomp.StateflowHalsteadDifficultyDistribution
Description
The Halstead complexity metrics measure the size and complexity of code, which can help you monitor code quality, identify complex areas in the design, and address software maintainability concerns. One of the Halstead complexity metrics is Halstead difficulty. Halstead difficulty is an estimate of how difficult the code is to read and write, calculated based on the number of total and unique operators and operands in the design.
Use this metric to calculate the distribution of Halstead difficulty across the Stateflow® charts in your units and components.
Supported Artifacts
You can collect this metric for:
To control what the dashboard classifies as a unit or component, see Categorize Models in Hierarchy as Components or Units.
Computation Details
For information on how the metric calculates Stateflow Halstead difficulty, see Stateflow Halstead Complexity.
Collection
To collect data for this metric, execute the metric engine and use getMetrics
with the metric
ID
slcomp.StateflowHalsteadDifficultyDistribution
.
metric_engine = metric.Engine; execute(metric_engine,"slcomp.StateflowHalsteadDifficultyDistribution"); results = getMetrics(metric_engine,"slcomp.StateflowHalsteadDifficultyDistribution")
Results
The metric returns results for each unit and component in the project.
For each unit and component, the metric returns a metric.Result
object with properties including:
Value
— Structure that represents the distribution of Simulink® Halstead difficulties in the unit or component. The structure contains these fields:BinCounts
— The number of Stateflow charts, states, and truth tables in each bin, returned as a vector.BinEdges
— Bin edges for the Stateflow Halstead difficulties, returned as a vector.BinEdges(1)
is the left edge of the first bin andBinEdges(end)
is the right edge of the last bin. The length ofBinEdges
is one more than the length ofBinCounts
.
For information on MATLAB® Halstead difficulty, see Stateflow Halstead Difficulty.
Scope
— Structure with information about the unit or component.
See Also
Model Maintainability Metrics | Stateflow Halstead Complexity | Stateflow Halstead Difficulty