apple / darwin-xnu
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,106 units with 45,961 lines of code in units (4.1% of code).
    • 55 very long units (9,877 lines of code)
    • 146 long units (10,034 lines of code)
    • 422 medium size units (13,559 lines of code)
    • 496 small units (7,231 lines of code)
    • 987 very small units (5,260 lines of code)
21% | 21% | 29% | 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
c32% | 27% | 30% | 7% | 2%
py11% | 16% | 31% | 23% | 17%
h21% | 7% | 9% | 25% | 37%
m0% | 74% | 17% | 6% | 2%
lua0% | 23% | 35% | 17% | 23%
pl0% | 27% | 44% | 21% | 6%
cpp0% | 0% | 0% | 36% | 63%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
bsd26% | 31% | 32% | 7% | 2%
osfmk36% | 23% | 29% | 7% | 3%
tools10% | 17% | 31% | 23% | 17%
libkdd87% | 11% | 0% | 0% | <1%
libkern29% | 21% | 20% | 16% | 12%
iokit89% | 0% | 0% | 6% | 4%
libsyscall0% | 40% | 41% | 13% | 5%
san0% | 57% | 28% | 0% | 13%
EXTERNAL_HEADERS0% | 0% | 6% | 30% | 63%
config0% | 0% | 0% | 80% | 20%
pexpert0% | 0% | 0% | 100% | 0%
security0% | 0% | 0% | 0% | 100%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
691 93 5
static __attribute__()
in bsd/net/if.c
687 186 1
386 3 3
int main()
in osfmk/i386/genassym.c
337 2 2
336 40 5
310 74 9
reswitch: switch()
in iokit/Kernel/IOHibernateRestoreKernel.c
290 116 1
struct __attribute__()
in libkern/libkern/c++/bounded_ptr.h
221 12 1
static __attribute__()
in bsd/netinet/in.c
218 34 1
static __attribute__()
in bsd/net/if.c
215 209 1
int main()
in osfmk/arm/genassym.c
215 2 2
def ShowAllSetidLinks()
in tools/lldbmacros/waitq.py
208 103 2
def DumpRawTraceFile()
in tools/lldbmacros/misc.py
197 43 2
int main()
in osfmk/arm64/genassym.c
191 2 2
__asm__ volatile()
in osfmk/arm64/pcb.c
185 37 1
def SaveStackshotReport()
in tools/lldbmacros/kcdata.py
179 50 3
178 1 3
static int rip6_pr_output()
in bsd/netinet6/in6_proto.c
173 1 4
static ZONE_DECLARE()
in bsd/net/dlil.c
164 2 3
static int key_spdadd()
in bsd/netkey/key.c
160 5 3