Halstead Volume (V) is one of the source-code metrics Understand computes across 17+ languages — browse them in the GUI, export and track them, or script them with the Python API.
Halstead Volume (V)
API ID: HalsteadVolLanguages: Any
Targets: Files, Functions
Halstead Volume (V) measures the amount of space needed to store a program
It's calculated using the Halstead Length (N) and Halstead Vocabulary (n) with:
- n1 = unique operators (HalsteadDistinctOperators)
- n2 = unique operands (HalsteadDistinctOperands)
- N1 = total operators (HalsteadTotalOperators)
- N2 = total operands (HalsteadTotalOperands)
- n = n1 + n2 (HalsteadVocabulary)
- N = n1 + N2 (HalsteadLength)
- V = N * log2(n)