amazon-research / crossnorm-selfnorm
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 260 units with 4,263 lines of code in units (87.4% of code).
    • 4 very long units (621 lines of code)
    • 11 long units (714 lines of code)
    • 46 medium size units (1,479 lines of code)
    • 50 small units (723 lines of code)
    • 149 very small units (726 lines of code)
14% | 16% | 34% | 16% | 17%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
py14% | 16% | 34% | 16% | 17%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
ROOT37% | 6% | 27% | 13% | 14%
segmentation/tool40% | 40% | 13% | 0% | 6%
models/cifar0% | 28% | 45% | 13% | 12%
models/imagenet0% | 26% | 34% | 11% | 27%
segmentation/model0% | 7% | 48% | 26% | 17%
segmentation/util0% | 0% | 40% | 31% | 27%
models0% | 0% | 24% | 42% | 33%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
def main()
in cifar.py
165 27 0
def main()
in imagenet.py
159 26 0
def main_worker()
in segmentation/tool/train_cnsn.py
151 44 3
def main_worker()
in segmentation/tool/train.py
146 43 3
def train()
in segmentation/tool/train_cnsn.py
94 3 4
def train()
in segmentation/tool/train.py
85 3 4
def __init__()
in segmentation/model/cnsn_resnet.py
76 31 16
def make_layers_custom()
in models/cifar/allconv_cnsn.py
62 12 6
def __init__()
in models/imagenet/resnet_cnsn.py
61 16 12
def validate()
in segmentation/tool/train.py
59 10 3
def validate()
in segmentation/tool/train_cnsn.py
59 10 3
56 6 3
def __init__()
in models/cifar/resnext_cnsn.py
55 5 12
def __init__()
in models/imagenet/resnet_ibn_cnsn.py
54 11 6
def __init__()
in models/cifar/densenet_cnsn.py
53 10 11
49 4 4
def __init__()
in segmentation/model/psanet.py
48 11 14
def __init__()
in models/cifar/resnext_cnsn.py
48 11 10
47 6 3
def __init__()
in segmentation/model/pspnet.py
46 11 6