Quantcast
Loading [MathJax]/jax/output/CommonHTML/jax.js

Halstead Software Complexity

Last modified by
on
Sep 29, 2022, 12:50:40 AM
Created by
on
Dec 11, 2020, 3:24:39 PM
HC=f(N1,N2,η1,η2)
(N1)Total Number of Operators
(N2)total number of operands
(η1)Number of distinct operators
(η2)Number of distinct operands

The Halstead Complexity calculator computes several code factors based the total and unique number of operators and operands.

INSTRUCTIONS: Enter the following:

  • (N1) Total number of operators
  • (N2) Total number of operands
  • 1) Number of unique operators
  • 2) Number of unique operands

Halstead Complexity (HC): The calculator returns the following:

  • Program vocabulary
  • Program length
  • Calculated estimated program length
  • Volume of Code
  • Software Difficulty 
  • Software Effort 
  • Time to Write Code
  • Estimated Number of Delivered Bugs

The Math / Science

Halstead Complexity calculations were intended to provide software metrics established as an empirical science of software development.  For a software development effort, one can use the following metrics to characterize the level of complexity of developing the software:

  • η1 = the number of distinct operators
  • η2 = the number of distinct operands
  • N1 = the total number of operators
  • N2 = the total number of operands

From these numbers, several measures can be calculated:

  • Program vocabulary: η = η1 + η2
  • Program length: N = N1 + N2
  • Calculated estimated program length: L = η1 * log21) + η2* log22)
  • Volume of Code: V=N * log2(η) 
  • Software Difficulty: D = (η1/2) * (N2 / η2
  • Software Effort: E = D*V
  • Time to Write Code: T = (E/18) seconds
  • Estimated Number of Delivered Bugs: B = V/3000

Note: The difficulty measure is related to the difficulty of the program to write or understand, e.g. when doing code review.  


  • Comments
  • Attachments
  • Stats
No comments
This site uses cookies to give you the best, most relevant experience. By continuing to browse the site you are agreeing to our use of cookies.