- Rule (a): The path count for a sequence of non-control statements is 1.
- Rule (b): For an if statement, the path count is the sum of the paths in the then block and the else block.
- Rule (c): For loops (while, do-while, for), the path count is the paths in the loop body plus 1.
- Rule (d): For a switch statement, the path count is the sum of the paths for each case body.
- Rule (e): For consecutive control statements, the path count is the product of the path counts of the individual control statements. This applies to control structures such as if, while, do-while, for, and switch.
Why is the "Number of Paths" function metric in polyspace CMM report giving unusual values?
16 次查看(过去 30 天)
显示 更早的评论
During Polyspace analysis of software components, the CMM report that is generated contains many metrics including the "Number of Paths".As per MATLAB documentation, "Number of Paths" is a function metric which gives the number of estimated static path count.
While Polyspace analysis was launched on many software components, a strange behaviour was observed. Most of the values were abnormal like, 2147483647, 264446471, 184570425, 30722 and so on.
I am unable to understand why I am receiving such high values for the Number of Paths.
0 个评论
回答(1 个)
Akshat Dalal
2024-10-26,9:35
Polyspace computes the estimated static path count within a function, which represents the potential execution paths software can identify. The algorithm used by Polyspace is as follows:
It's important to note that a for loop inherently has at least two paths. Consequently, according to Rule (e), two consecutive for loops will have a minimum path count of 4.
The paths computed by Polyspace reflect the definition of the estimated static path count. A high number of paths indicates that the routine contains numerous sequential control blocks, which are influenced by Rule (e). This rule also implies that the total number of paths in a routine increases rapidly with the number of loops or if statements.
For example, consider the below function:
void function(void) {
int i = 0, j = 0;
if (i == j);
if (i == j);
if (i == j);
if (i == j);
if (i == j);
if (i == j);
if (i == j);
if (i == j);
if (i == j);
for (i = 0; i < 10; i++) {
for (j = 0; j < 10; j++) {
if (i == 0) {
;
}
}
}
}
The Path metrics is 2048 for this simple function.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Polyspace Code Prover 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!