facebookresearch / moco
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 43 units with 601 lines of code in units (66.9% of code).
    • 2 very long units (235 lines of code)
    • 0 long units (0 lines of code)
    • 5 medium size units (135 lines of code)
    • 7 small units (92 lines of code)
    • 29 very small units (139 lines of code)
39% | 0% | 22% | 15% | 23%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
py39% | 0% | 22% | 15% | 23%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
ROOT48% | 0% | 27% | 7% | 16%
moco0% | 0% | 0% | 54% | 45%
detection0% | 0% | 0% | 36% | 63%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
def main_worker()
in main_lincls.py
132 41 3
def main_worker()
in main_moco.py
103 28 3
def train()
in main_moco.py
30 6 6
def train()
in main_lincls.py
30 6 6
def validate()
in main_lincls.py
29 5 4
def main()
in main_moco.py
23 7 0
def main()
in main_lincls.py
23 7 0
def __init__()
in moco/builder.py
17 3 7
def forward()
in moco/builder.py
16 3 3
def accuracy()
in main_moco.py
12 2 3
def sanity_check()
in main_lincls.py
12 5 2
def accuracy()
in main_lincls.py
12 2 3
def main()
in detection/train_net.py
12 2 1
def _batch_shuffle_ddp()
in moco/builder.py
11 3 2
9 5 3
def _dequeue_and_enqueue()
in moco/builder.py
8 3 2
def _batch_unshuffle_ddp()
in moco/builder.py
8 2 3
def build_evaluator()
in detection/train_net.py
8 3 4
def setup()
in detection/train_net.py
7 1 1
def concat_all_gather()
in moco/builder.py
6 2 1