openai / openai-icpc-2025
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...
  • To learn more about unit size, the Sokrates recommends the following resources:
    • Function Length, MartinFowler.com
      • "If you have to spend effort into looking at a fragment of code to figure out what it's doing, then you should extract it into a function and name the function after that 'what'."
    • Stack Overflow Discussion on Unit Size, stackoverflow.com
      • "Use common sense, stick to small function sizes in most instances but don't be dogmatic about it if you have a genuinely good reason to make an unusually big function."
    • Coding Smells, codinghorror.com
      • "All other things being equal, a shorter method is easier to read, easier to understand, and easier to troubleshoot. Refactor long methods into smaller methods if you can."
    • Clean Code: A Handbook of Agile Software Craftsmanship, by Robert Martin
      • "The first rule of functions is that they should be small. The second rule of functions is that they should be smaller than that. Functions should not be 100 lines long. Functions should hardly ever be 20 lines long."
Unit Size Overall
  • There are 84 units with 2,739 lines of code in units (87.8% of code).
    • 8 very long units (1,477 lines of code)
    • 9 long units (569 lines of code)
    • 7 medium size units (211 lines of code)
    • 19 small units (273 lines of code)
    • 41 very small units (209 lines of code)
53% | 20% | 7% | 9% | 7%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
cpp53% | 20% | 7% | 9% | 7%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
G-Lava Moat69% | 5% | 4% | 12% | 7%
C-Bride of Pipe Stream86% | 0% | 0% | 13% | 0%
A-A-Skew-ed Reasoning0% | 95% | 0% | 0% | 4%
I-Slot Machine0% | 100% | 0% | 0% | 0%
H-Score Values0% | 54% | 26% | 0% | 19%
K-Treasure Map0% | 100% | 0% | 0% | 0%
D-Buggy Rover0% | 100% | 0% | 0% | 0%
F-Herding Cats0% | 100% | 0% | 0% | 0%
J-Stacking Cups0% | 89% | 0% | 0% | 10%
E-Delivery Service0% | 0% | 58% | 14% | 27%
L-Walking on Sunshine0% | 0% | 100% | 0% | 0%
B-Blackboard Game0% | 0% | 0% | 0% | 100%
Alternative Visuals
Longest Units
Top 50 longest units
Unit# linesMcCabe index# params
262 77 0
244 62 0
211 54 0
192 39 0
171 37 0
163 41 0
128 33 0
106 15 0
82 36 0
67 27 0
66 29 0
64 16 0
63 26 0
62 22 0
61 16 0
52 13 0
52 23 0
45 12 2
41 11 0
32 13 5
27 9 2
23 5 2
22 7 2
21 2 0
20 3 4
19 5 1
17 3 1
16 6 1
16 4 1
15 3 4
15 3 1
15 3 4
15 3 1
14 2 3
14 4 1
14 4 1
14 5 0
13 3 1
12 3 4
11 2 1
11 3 4
11 2 1
11 4 0
10 6 2
10 2 3
9 2 1
9 1 0
9 3 7
9 2 1
8 3 0