Main Content

metric.Engine

Collect metric data on models

Description

A metric.Engine object represents the metric engine that you can execute with the execute object function to collect metric data on your design. Use the getMetrics function to access the metric data and return an array of metric.Result objects. Use generateReport to access a detailed report of metrics collected. Use design cost metric data to estimate the cost of implementing your design in embedded C code. For additional metrics, see Model Testing Metrics (Simulink Check).

Creation

Description

example

metric_engine = metric.Engine() creates a metric engine object that collects metric data on the current project.

example

metric_engine = metric.Engine(projectPath) opens the project projectPath and creates a metric engine object that collects metric data on the project.

Input Arguments

expand all

Path of project for which to collect metric data, specified as a character vector or string scalar.

Properties

expand all

This property is read-only.

Project for which engine collects metric data, returned as a string.

Object Functions

deleteMetricsDelete metric results for model testing artifacts
executeCollect metric data
generateReportGenerate report file that contains metric results
getArtifactErrorsReturn errors that occurred during metric execution
getAvailableMetricIdsReturn metric identifiers for available metrics
getMetricsAccess metric data for model testing artifacts
openArtifactOpen testing artifact traced from metric result
updateArtifactsUpdate trace information for pending artifact changes in project

Examples

collapse all

Use a metric.Engine object to collect design cost metric data on a model reference hierarchy in a project. This example requires Simulink Check to run.

To open the project, enter this command.

dashboardCCProjectStart

The project contains db_Controller, which is the top-level model in a model reference hierarchy. This model reference hierarchy represents one design unit.

Create a metric.Engine object.

metric_engine = metric.Engine();

Update the trace information for metric_engine to reflect any pending artifact changes.

updateArtifacts(metric_engine)

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.

execute(metric_engine,metric_Ids);

Because the engine was executed without the argument for ArtifactScope, the engine collects metrics for the db_Controller model reference hierarchy.

Use the generateReport function to access detailed metric results in a pdf report. Name the report 'MetricResultsReport.pdf'.

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.

Table of contents for generated report.

Version History

Introduced in R2022a