Contenu principal

Clone Detection

R2026b
Since R2026b

Metric ID

slcomp.CloneDetectionMetric

Description

This metric returns clone detection results for each unit in your project, including the number of clone groups, similar clones, and exact clones. Use this metric to identify opportunities for design reuse by refactoring repeated modeling patterns. For more information about clone detection, see Enable Component Reuse by Using Clone Detection.

Supported Artifacts

This metric collects metric results for Units in the project. To control what the dashboard classifies as a unit, see Categorize Models in Hierarchy as Components or Units.

Collection

To collect data for this metric, execute the metric engine with the metric ID.

metric_engine = metric.Engine;
results = execute(metric_engine,"slcomp.CloneDetectionMetric")

View the metric result values for a specific unit.

results(1).Value
results(1).ScopeAlias

Results

The metric returns an array of metric.Result objects, one for each unit in the project. Use the Value property of the metric result object to view the metric result values. Use the ScopeId and ScopeAlias properties to identify which unit the result belongs to.

The ScopeAlias property returns the name of the unit.

The Value property returns missing when clone detection has not been run for the unit. When clone detection results exist, the Value property returns a structure with these fields:

  • CloneGroups — Number of groups of repeated modeling patterns detected in the unit

  • SimilarClones — Number of clones that have identical block types and signal connections, but with at least one differing block parameter value

  • ExactClones — Number of clones that have identical block types, signal connections, and block parameter values

  • Clones — Total number of clones, equal to the sum of SimilarClones and ExactClones

  • Timestamp — Time when clone detection was last run, in milliseconds. To convert to a readable date, use datetime(result.Timestamp/1000,'ConvertFrom','posixtime').

See Also

Topics