Linux / Tools
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 16,035 units with 315,398 lines of code in units (62.2% of code).
    • 257 very long units (40,064 lines of code)
    • 935 long units (63,314 lines of code)
    • 3,454 medium size units (107,915 lines of code)
    • 4,028 small units (59,268 lines of code)
    • 7,361 very small units (44,837 lines of code)
12% | 20% | 34% | 18% | 14%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
c12% | 20% | 35% | 18% | 12%
py16% | 11% | 20% | 21% | 29%
h11% | 21% | 14% | 14% | 38%
pl13% | 24% | 30% | 16% | 14%
pm0% | 0% | 33% | 31% | 35%
cpp0% | 0% | 27% | 27% | 45%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
perf11% | 17% | 33% | 20% | 16%
testing10% | 23% | 36% | 18% | 11%
power21% | 19% | 29% | 20% | 9%
lib16% | 17% | 31% | 17% | 15%
bpf13% | 26% | 37% | 13% | 8%
objtool26% | 23% | 30% | 13% | 5%
iio46% | 23% | 17% | 10% | 3%
vm24% | 17% | 27% | 20% | 9%
usb14% | 21% | 40% | 13% | 10%
hv25% | 30% | 32% | 5% | 6%
tracing10% | 18% | 31% | 22% | 16%
accounting62% | 0% | 28% | 0% | 8%
thermal9% | 16% | 48% | 17% | 8%
firewire85% | 0% | 0% | 14% | 0%
pci54% | 45% | 0% | 0% | 0%
gpio15% | 39% | 24% | 11% | 9%
io_uring0% | 33% | 33% | 14% | 18%
arch0% | 19% | 34% | 18% | 26%
firmware0% | 74% | 0% | 8% | 17%
bootconfig0% | 35% | 37% | 25% | 1%
virtio0% | 8% | 25% | 19% | 46%
laptop0% | 25% | 34% | 15% | 25%
include0% | 0% | 9% | 17% | 73%
cgroup0% | 0% | 34% | 40% | 24%
spi0% | 0% | 100% | 0% | 0%
build0% | 0% | 19% | 23% | 57%
wmi0% | 0% | 53% | 28% | 18%
leds0% | 0% | 100% | 0% | 0%
counter0% | 0% | 100% | 0% | 0%
rcu0% | 0% | 0% | 100% | 0%
pcmcia0% | 0% | 0% | 52% | 47%
Alternative Visuals
Longest Units
Top 50 longest units
Unit# linesMcCabe index# params
491 83 2
442 92 2
388 48 1
387 1 2
385 127 2
385 127 2
385 100 8
379 91 9
354 85 2
343 98 3
334 69 2
326 101 7
312 45 2
310 24 2
300 62 2
292 52 1
288 101 2
281 73 1
269 55 1
263 67 2
257 100 0
253 1 1
252 62 2
251 47 3
250 72 1
246 182 3
244 50 3
242 121 3
238 51 3
229 70 2
228 38 1
226 106 4
219 15 1
219 73 3
218 59 7
218 52 2
213 42 2
210 69 2
208 52 2
207 56 6
207 55 2
206 72 5
205 32 1
201 59 3
199 94 3
199 54 3
197 54 0
196 41 2
196 38 4
193 32 2