golang / benchmarks
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 729 units with 11,139 lines of code in units (62.6% of code).
    • 11 very long units (2,020 lines of code)
    • 25 long units (1,674 lines of code)
    • 99 medium size units (2,947 lines of code)
    • 162 small units (2,304 lines of code)
    • 432 very small units (2,194 lines of code)
18% | 15% | 26% | 20% | 19%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
go18% | 15% | 26% | 20% | 19%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
cmd/bent69% | 5% | 11% | 5% | 8%
garbage10% | 17% | 31% | 17% | 23%
sweet/generators53% | 25% | 3% | 4% | 12%
sweet/cmd31% | 16% | 28% | 11% | 10%
sweet/benchmarks6% | 18% | 32% | 22% | 18%
driver0% | 20% | 15% | 47% | 15%
sweet/source-assets0% | 83% | 0% | 0% | 16%
stats0% | 0% | 53% | 18% | 28%
sweet/cli0% | 0% | 46% | 22% | 30%
cmd/bench0% | 0% | 48% | 44% | 7%
sweet/common0% | 0% | 15% | 41% | 42%
http0% | 0% | 51% | 26% | 21%
build0% | 0% | 57% | 35% | 7%
sweet/harnesses0% | 0% | 7% | 62% | 30%
json0% | 0% | 0% | 62% | 37%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
func main()
in cmd/bent/bent.go
779 190 0
func Markdown()
in sweet/generators/copy.go
193 1 0
func()
in garbage/nethttp.go
158 63 1
func()
in sweet/generators/tile38.go
130 32 1
func()
in sweet/cmd/sweet/run.go
122 34 1
func()
in sweet/cmd/sweet/benchmark.go
111 28 1
func()
in garbage/nethttp.go
110 25 1
func()
in cmd/bent/configuration.go
108 20 1
func()
in garbage/nethttp.go
104 24 1
func()
in sweet/benchmarks/gvisor/http_server.go
103 18 1
func()
in garbage/nethttp.go
102 36 1
func()
in sweet/generators/gvisor.go
98 21 1
func serveContent()
in garbage/nethttp.go
92 20 5
func readTransfer()
in garbage/nethttp.go
90 23 2
func()
in garbage/nethttp.go
84 24 1
func readSetCookies()
in garbage/nethttp.go
83 23 1
func()
in garbage/nethttp.go
77 24 1
func()
in garbage/nethttp.go
75 24 1
func RunBenchmark()
in sweet/benchmarks/internal/driver/driver.go
74 25 2
func()
in sweet/cmd/sweet/gen.go
72 18 1