Static metrics overview
Statistical measurement of source code properties is an extremely important matter when you are planning your test work for a software project. IBM® Rational® Test RealTime provides a static metrics report, which displays complexity data and statistics for your source code.
Halstead metrics
Halstead complexity measurement was developed to measure a program module's complexity directly from source code, with emphasis on computational complexity. The measures were developed by the late Maurice Halstead as a means of determining a quantitative measure of complexity directly from the operators and operands in the module.
Halstead provides various indicators of the module's complexity
Parameter | Meaning |
---|---|
n1 | Number of distinct operators |
n2 | Number of distinct operands |
N1 | Number of operator instances |
N2 | Number of operand instances |
Metric | Meaning | Formula |
---|---|---|
n | Vocabulary | n1 + n2 |
N | Size | N1 + N2 |
V | Volume | N * log2 n |
D | Difficulty | n1/2 * N2/n2 |
E | Effort | V * D |
B | Errors | V / 3000 |
T | Testing time | E / k |
When the project is selected, the metrics viewer displays the total testing time for the entire project.
V(g) or cyclomatic number
The V(g) or cyclomatic number is a measure of the complexity of a source code function that is correlated with difficulty in testing. The standard value is between 1 and 10. A value of 1 means the code has no branching. A function's cyclomatic complexity should not exceed 10.
The static metrics report displays the V(g) of a function in the Metrics tab when a source file or function is selected. When the type of the selected node is a source file, the sum of the V(g) of the contained function, the mean, the maximum and the standard deviation are calculated.
At the project level, the same statistical treatment is provided for every function in any source file.