Collect metric data
collects metric results for the artifacts in the specified
example, you can specify
scope to be a single design unit in your
project, such as a Simulink® model or an entire model reference hierarchy. A unit is a functional entity in
your software architecture that you can execute and test independently or as part of larger
Collect Metric Data for Each Design Unit in Project
metric.Engine object to collect design cost
metric data on a model reference hierarchy in a project.
To open the project, enter this command.
The project contains
db_Controller, which is the top-level model
in a model reference hierarchy. This model reference hierarchy represents one design
metric_engine = metric.Engine();
Update the trace information for
metric_engine to reflect
any pending artifact changes.
Create an array of metric identifiers for the metrics you want to collect. For this example, create a list of all available design cost estimation metrics.
metric_Ids = getAvailableMetricIds(metric_engine,... 'App','DesignCostEstimation')
metric_Ids = 1×2 string array "DataSegmentEstimate" "OperatorCount"
To collect results, execute the metric engine.
Because the engine was executed without the argument for
ArtifactScope, the engine collects metrics for the
db_Controller model reference hierarchy.
generateReport function to access detailed metric
results in a pdf report. Name the report
reportLocation = fullfile(pwd,'MetricResultsReport.pdf'); generateReport(metric_engine,... 'App','DesignCostEstimation',... 'Type','pdf',... 'Location',reportLocation);
The report contains a detailed breakdown of the operator count and data segment estimate metric results.
metricEngine — Metric engine object
Metric engine object for which to collect metric results, specified as a
metricIDs — Metric identifiers
character vector | cell array of character vectors
Metric identifiers for metrics to collect, specified as a character vector or cell array of character vectors. Collecting results for design cost metrics requires a Fixed-Point Designer™ license. For a list of design cost metrics and their identifiers, see Design Cost Model Metrics. For additional metrics, see Model Testing Metrics (Simulink Check).
scope — Path and identifier of project file
cell array of character vectors
Path and identifier of project file for which to execute metric results, specified as a cell array of character vectors. The first entry is the full path to a project file. The second entry is the identifier of the object inside the project file.
For a unit model, the first entry is the full path to the model file. The second entry is the name of the block diagram. When you use this argument, the metric engine executes the metrics for the artifacts that trace to specified project file.
Introduced in R2022a