Halstead Effort (E) 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 Effort (E)
API ID: HalsteadEffortLanguages: Any
Targets: Files, Functions
Halstead Effort (E) measures coding time
Where Time is E/18 seconds. It's calculated from the Halstead Difficult (D) and Halstead Volume (V) as:
- 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) (HalsteadVol)
- D = (n1 / 2) * (N2 / n2) (HalsteadDifficulty)
- E = D * V