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.

HCL OneTest™ Embedded 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

Halstead metrics allow you to evaluate the testing time of any C/C++ source code. These only make sense at the source file level and vary with the following parameters:
Table 1.
Parameter Meaning
n1 Number of distinct operators
n2 Number of distinct operands
N1 Number of operator instances
N2 Number of operand instances
When a source file is selected in the metrics report, the following results are displayed:
Table 2.
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
In the above formulae, k is the stroud number, which has an arbitrary default value of 18. With experience, you can adjust the stroud number to adapt the calculation of the estimated testing time (T) to your own testing conditions: team background, criticity level, and so on.

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.