facebook / zstd
Unit Size

The distribution of size of units (measured in lines of code).

Intro
  • Unit size measurements show the distribution of size of units of code (methods, functions...).
  • Units are classified in four categories based on their size (lines of code): 1-20 (small units), 20-50 (medium size units), 51-100 (long units), 101+ (very long units).
  • You should aim at keeping units small (< 20 lines). Long units may become "bloaters", code that have increased to such gargantuan proportions that they are hard to work with.
Learn more...
Unit Size Overall
  • There are 2,159 units with 40,501 lines of code in units (59.3% of code).
    • 45 very long units (6,780 lines of code)
    • 149 long units (10,035 lines of code)
    • 303 medium size units (9,609 lines of code)
    • 471 small units (6,895 lines of code)
    • 1,191 very small units (7,182 lines of code)
16% | 24% | 23% | 17% | 17%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
c17% | 25% | 24% | 16% | 15%
cpp43% | 11% | 26% | 7% | 9%
py18% | 20% | 25% | 18% | 16%
h0% | 12% | 17% | 21% | 49%
lua0% | 100% | 0% | 0% | 0%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
lib/compress24% | 20% | 20% | 19% | 15%
lib/legacy10% | 38% | 21% | 14% | 14%
programs21% | 14% | 25% | 18% | 19%
lib/decompress20% | 20% | 23% | 19% | 15%
lib/dictBuilder24% | 26% | 28% | 10% | 10%
zlibWrapper15% | 23% | 27% | 18% | 14%
contrib/pzstd25% | 10% | 22% | 12% | 28%
contrib/match_finders52% | 0% | 36% | 4% | 6%
contrib/freestanding_lib22% | 25% | 25% | 11% | 15%
contrib/gen_html73% | 0% | 0% | 17% | 8%
lib/common5% | 8% | 19% | 20% | 45%
contrib/largeNbDicts0% | 30% | 29% | 21% | 17%
contrib/seekable_format0% | 27% | 25% | 18% | 28%
doc/educational_decoder0% | 8% | 59% | 18% | 13%
contrib/diagnose_corruption0% | 36% | 42% | 13% | 7%
contrib/premake0% | 100% | 0% | 0% | 0%
contrib/recovery0% | 55% | 31% | 0% | 13%
build/single_file_libs0% | 0% | 43% | 43% | 13%
contrib/linux-kernel0% | 0% | 11% | 0% | 88%
lib/deprecated0% | 0% | 19% | 54% | 25%
build/meson0% | 0% | 0% | 64% | 35%
Alternative Visuals
Longest Units
Top 50 longest units
Unit# linesMcCabe index# params
608 224 2
267 85 2
256 56 3
203 61 10
196 59 7
185 51 3
181 30 6
171 40 2
170 39 6
168 48 4
159 36 1
159 28 9
155 37 3
149 27 7
146 46 7
145 26 6
145 25 7
142 27 5
140 31 5
135 33 6
134 30 5
127 38 1
127 23 5
127 35 3
125 16 6
122 39 2
122 35 6
122 22 6
120 19 6
120 31 5
119 31 3
118 29 5
116 31 3
115 31 3
113 17 13
112 4 1
111 21 5
110 19 6
110 33 9
108 22 10
105 18 5
105 18 5
105 18 5
105 18 5
102 18 6
100 6 11
98 28 2
98 26 1
94 24 5
92 13 8