Documentation

slmetric.Engine class

Package: slmetric
Superclasses:

Collect metric data on models or model components

Description

Use a slmetric.Engine object to collect metric data on models by calling slmetric.Engine.execute. Use slmetric.Engine.getMetrics to access the metric data and return an array of slmetric.metric.ResultCollection objects. This metric data is persistent in the simulation cache folder. Future instantiations of the slmetric.Engine object for the same model can access the cached metric data without regenerating the metric data.

Construction

metric_engine = slmetric.Engine() creates a metric engine object.

Properties

expand all

Name of root model or subsystem on which to collect metric data, as specified by the slmetric.Engine.setAnalysisRoot method. This property is read-only.

Specify if the metric engine analyzes library-linked subsystems in the root model, including libraries inside referenced models under the root. Metric analysis does not include linked blocks to Simulink built-in libraries. Set this parameter to false or 0 to not include libraries in the metric analysis.

Data Types: logical

Specify if the metric engine analyzes referenced models in your root model. Set this parameter to false or 0 to not include referenced models in the metric analysis.

Data Types: logical

Methods

executeCollect metric data
exportMetricsExport model metrics
getAnalysisRootMetricGet metric data for one metric for analysis root only
getErrorLogGet error log
getMetricDistributionGet metric distribution
getMetricsAccess model metric data
getStatisticsGet statistics on metric data
setAnalysisRootSpecify model or subsystem for metric analysis

Examples

expand all

Collect and access model metric data for the model sldemo_mdlref_basic.

Create an slmetric.Engine object and set the root in the model for analysis.

metric_engine = slmetric.Engine();

% Include referenced models and libraries in the analysis, these properties are on by default
metric_engine.AnalyzeModelReferences = 1;
metric_engine.AnalyzeLibraries = 1;

setAnalysisRoot(metric_engine, 'Root',  'sldemo_mdlref_basic');

Collect model metric data

execute(metric_engine, 'mathworks.metrics.SimulinkBlockCount');

Get the model metric data that returns an array of slmetric.metric.ResultCollection objects, res_col.

res_col = getMetrics(metric_engine, 'mathworks.metrics.SimulinkBlockCount');

Display the results for the mathworks.metrics.SimulinkBlockCount metric.

for n=1:length(res_col)
    if res_col(n).Status == 0
        result = res_col(n).Results;
        
        for m=1:length(result)
            disp(['MetricID: ',result(m).MetricID]);
            disp(['  ComponentPath: ', result(m).ComponentPath]);
            disp(['  Value: ', num2str(result(m).Value)]);
            disp(['  AggregatedValue: ', num2str(result(m).AggregatedValue)]);
        end
    else
        disp(['No results for:', result(n).MetricID]);
    end
    disp(' ');
end

Introduced in R2016a

Was this topic helpful?