facebook / rocksdb
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 15,005 units with 176,450 lines of code in units (66.6% of code).
    • 188 very long units (31,552 lines of code)
    • 367 long units (25,077 lines of code)
    • 1,264 medium size units (39,298 lines of code)
    • 2,126 small units (30,965 lines of code)
    • 11,060 very small units (49,558 lines of code)
17% | 14% | 22% | 17% | 28%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
cc21% | 17% | 24% | 17% | 18%
h6% | 4% | 16% | 21% | 52%
java4% | 1% | 8% | 9% | 76%
py3% | 19% | 25% | 24% | 27%
c0% | 0% | 60% | 23% | 15%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
db29% | 15% | 22% | 13% | 19%
tools28% | 22% | 23% | 11% | 12%
db_stress_tool44% | 19% | 18% | 6% | 11%
table16% | 21% | 26% | 16% | 19%
utilities10% | 12% | 29% | 23% | 24%
java6% | 5% | 14% | 19% | 53%
util11% | 9% | 24% | 24% | 30%
options19% | 24% | 31% | 16% | 8%
file15% | 32% | 21% | 16% | 14%
trace_replay21% | 15% | 31% | 16% | 15%
memtable14% | 4% | 12% | 22% | 45%
env2% | 6% | 23% | 34% | 33%
buckifier37% | 0% | 0% | 35% | 27%
microbench9% | 49% | 19% | 16% | 5%
port0% | 20% | 26% | 24% | 28%
monitoring0% | 12% | 23% | 19% | 44%
logging0% | 21% | 17% | 23% | 37%
include0% | 0% | 10% | 12% | 77%
memory0% | 0% | 30% | 27% | 42%
build_tools0% | 0% | 21% | 23% | 54%
coverage0% | 0% | 31% | 68% | 0%
fuzz0% | 0% | 0% | 100% | 0%
Alternative Visuals
Longest Units
Top 50 longest units
Unit# linesMcCabe index# params
517 163 3
504 74 0
443 125 0
442 109 5
408 62 1
392 65 1
382 89 3
374 71 4
368 74 5
358 175 1
356 175 1
342 77 2
330 76 1
322 83 9
320 66 4
310 77 5
307 1 2
307 104 0
300 58 28
291 92 1
289 60 3
282 76 2
281 69 1
278 19 1
273 39 3
262 55 1
254 67 5
252 59 7
250 55 6
237 62 5
232 57 5
229 51 4
227 61 2
225 41 0
222 45 3
220 38 0
220 51 3
219 55 2
214 61 3
210 49 4
204 39 8
201 50 0
191 44 8
189 32 0
189 20 0
185 31 3
183 38 2
182 47 5
182 34 2
180 36 1