Linux / Samples
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 806 units with 18,987 lines of code in units (70.7% of code).
    • 15 very long units (2,143 lines of code)
    • 81 long units (5,568 lines of code)
    • 190 medium size units (6,159 lines of code)
    • 198 small units (2,950 lines of code)
    • 322 very small units (2,167 lines of code)
11% | 29% | 32% | 15% | 11%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
c11% | 29% | 32% | 15% | 11%
h0% | 22% | 43% | 23% | 10%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
bpf13% | 31% | 30% | 15% | 8%
vfio-mdev5% | 31% | 45% | 9% | 8%
seccomp22% | 23% | 34% | 16% | 3%
connector72% | 0% | 16% | 11% | 0%
vfs37% | 0% | 50% | 0% | 12%
nitro_enclaves0% | 72% | 18% | 7% | 1%
uhid0% | 58% | 16% | 22% | 2%
landlock0% | 79% | 0% | 9% | 11%
hidraw0% | 100% | 0% | 0% | 0%
v4l0% | 21% | 11% | 40% | 26%
acrn0% | 90% | 0% | 0% | 9%
kfifo0% | 17% | 53% | 22% | 7%
binderfs0% | 100% | 0% | 0% | 0%
mei0% | 0% | 76% | 15% | 8%
qmi0% | 0% | 82% | 7% | 10%
fanotify0% | 0% | 81% | 18% | 0%
auxdisplay0% | 0% | 46% | 19% | 33%
kprobes0% | 0% | 52% | 30% | 17%
pidfd0% | 0% | 72% | 0% | 27%
kmemleak0% | 0% | 86% | 0% | 13%
kobject0% | 0% | 15% | 39% | 45%
hw_breakpoint0% | 0% | 61% | 0% | 38%
configfs0% | 0% | 21% | 0% | 78%
ftrace0% | 0% | 0% | 35% | 64%
livepatch0% | 0% | 0% | 21% | 78%
trace_events0% | 0% | 0% | 47% | 52%
rpmsg0% | 0% | 0% | 89% | 10%
watchdog0% | 0% | 0% | 100% | 0%
trace_printk0% | 0% | 0% | 50% | 50%
kdb0% | 0% | 0% | 0% | 100%
coresight0% | 0% | 0% | 0% | 100%
Alternative Visuals
Longest Units
Top 50 longest units
Unit# linesMcCabe index# params
219 35 2
216 40 2
186 55 2
176 27 2
153 28 2
136 37 2
136 27 2
126 27 2
123 28 5
118 31 1
116 19 2
114 21 2
112 30 2
110 30 5
102 38 1
99 28 5
97 20 2
94 15 2
92 9 2
92 21 2
92 23 2
92 6 2
91 28 1
89 13 1
88 23 3
87 27 3
84 14 3
84 23 6
84 16 5
83 10 2
82 23 1
81 24 3
81 15 2
81 28 1
80 13 1
79 14 2
79 14 2
77 7 1
76 9 3
75 16 2
75 26 5
74 8 1
73 22 1
72 10 3
72 17 2
71 16 2
71 15 2
71 14 2
70 12 4
70 8 2