Paritian

Developers

Halstead Complexity Metrics Calculator (Volume, Difficulty, Effort)

Halstead volume, difficulty, effort, estimated writing time and delivered bugs of a program from its counts of operators and operands.

Results

Effort (E) 7728
Volume (V) 515.2
Difficulty (D) 15.00
Vocabulary (n) 30
Program length (N) 105
Estimated length from the vocabulary 118.1
Time to write it (T) 7.2 min
Estimated delivered bugs (B) 0.172

What this tool does

Maurice Halstead proposed in 1977 that a program can be measured by counting its operators (keywords, symbols, calls) and operands (variables and constants), distinct and in total. The vocabulary n and length N give the volume V = N log₂ n, difficulty is D = (n₁ ÷ 2)(N₂ ÷ n₂), which grows when few operands are reused, and effort is E = D × V. The conversions to 'time' (E ÷ 18 seconds) and 'bugs' (V ÷ 3000) come from his own calibration and are better read as relative indicators than as predictions. Tools differ in what they count as an operator, so compare numbers only from the same tool.

Formula

n = n₁ + n₂ · N = N₁ + N₂ · V = N log₂ n · D = (n₁ ÷ 2)(N₂ ÷ n₂) · E = D × V · T = E ÷ 18 s · B = V ÷ 3000

Variables

SymbolMeaningUnit
n1Distinct operators (n₁)—
n2Distinct operands (n₂)—
t1Total operators (N₁)—
t2Total operands (N₂)—
EEffort (E)—
VVolume (V)—
DDifficulty (D)—
VOVocabulary (n)—
LEProgram length (N)—
ELEstimated length from the vocabulary—
TITime to write it (T)min
BUEstimated delivered bugs (B)—

Worked example

  • Distinct operators (n₁)12
  • Distinct operands (n₂)18
  • Total operators (N₁)60
  • Total operands (N₂)45
  • Effort (E)7728
  • Volume (V)515.2
  • Difficulty (D)15.00
  • Vocabulary (n)30
  • Program length (N)105
  • Estimated length from the vocabulary118.1
  • Time to write it (T)7.2 min
  • Estimated delivered bugs (B)0.172

Limitations

  • The result is an estimate based only on the values you type. Real situations often include factors this calculator does not know about.
  • The default values are typical reference figures, not measurements of your situation. Replace them with your own data whenever you have it.