Halstead Complexity Report
The Halstead Complexity Report generates software metrics that are computed statically without program execution. Halstead complexity can be used to compare the complexity between two programs or two applications.
To define the Halstead Complexity Report settings for the current project, in Explore Projects view go to the Mainframe Reports list in the pane to the right. Then, select Complexity Reports, right-click on the Halstead Report and from the pop-up menu select Show settings.
In the Report settings dialog window, the Operators tab shows if a statement type is considered operator or operand when IBM® AD Analyze calculates the Halstead complexity. By default, all statement types are considered operators. Adjust the selections according to specific needs of your project. Use Check all and Clear all to manage the selection and Restore defaults to return to the default selection.
To generate this report, in Explore Projects view, go to the Mainframe Reports list in the pane to the right. Select Complexity Reports then double-click Halstead Complexity Report to display the report wizard.
The Available programs area displays the resources available for report generation and allows the user to select the resources to be included in the report. Use the Name field to filter the contents of the list. Place the cursor over an icon to display a tooltip about the type of resource it displays and click it to display only the selected type of resource. To display the full name of the resource type, click the white arrow button to the left of the dialog window.
In Report generation options area, the selection indicates that the report appendix is displayed by default. Choose what additional data you want to include in the appendix: show input details in appendix, show operators in appendix. To show only the report summary, select the appropriate option.
Use the arrow buttons to move the resources between the Available and Selected lists then click Finish to generate the report.
The Report summary section presents charts that show the Program length distribution, the Vocabulary size distribution, the Program volume distribution, the Difficulty level distribution, the Program level distribution, the Effort to implement distribution, the Time to implement distribution, and the Number of bugs distribution per program.
The Halstead Complexity Report details section shows for each program a chart that presents Program length, Vocabulary size, Program volume, Difficulty level, Program level, Effort to implement, Time to implement, and Number delivered bugs.
- Program length - measures the total number of operator occurrences and total number of
operand occurrences, representing the length metric for the
program.
N = N1 + N2
- Vocabulary size - measures the total number of unique operators and operands within the
program.
n = n1 + n2
- Program volume - measures the minimum number of bits required for coding the
program.
V = N * log2(n)
- Difficulty level - measures the level of difficulty in the
program.
D = (n1 / 2) * (N2 / n2)
- Program level - measures the level at which the program can be
understood.
L = 1 / D
- Effort - measures the mental effort that is required to develop or maintain the program.
The lower the value of this measure, the simpler the program would be to
change.
E = V * D
- Time to implement - measures the amount of time to implement the
algorithm.
T = E / 18
- Number of delivered bugs - measures the estimated number of errors in the
program.
B = ( E exp (2/3) ) / 3000
- n1 = the number of distinct operators
- n2 = the number of distinct operands
- N1 = the total number of operators
- N2 = the total number of operands