facebookresearch / luckmatters
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 308 units with 3,877 lines of code in units (83.9% of code).
    • 3 very long units (349 lines of code)
    • 9 long units (647 lines of code)
    • 33 medium size units (1,012 lines of code)
    • 52 small units (801 lines of code)
    • 211 very small units (1,068 lines of code)
9% | 16% | 26% | 20% | 27%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
py9% | 16% | 26% | 20% | 27%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
ssl/real-dataset14% | 48% | 13% | 9% | 14%
student_specialization11% | 6% | 31% | 18% | 31%
ssl/hltm43% | 0% | 8% | 32% | 14%
luckmatter0% | 17% | 27% | 26% | 28%
student_specialization/visualization0% | 0% | 78% | 8% | 13%
ssl/common_utils0% | 0% | 16% | 29% | 53%
ssl/real-dataset/loss0% | 0% | 48% | 18% | 33%
ssl/real-dataset/models0% | 0% | 23% | 36% | 40%
ssl/real-dataset/data0% | 0% | 35% | 41% | 23%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
def regulate_predictor()
in ssl/real-dataset/byol_trainer.py
127 56 4
def main()
in student_specialization/recon_multilayer.py
120 34 1
def main()
in ssl/hltm/simCLR_hltm.py
102 20 1
def update()
in ssl/real-dataset/byol_trainer.py
100 24 3
def eval_models()
in luckmatter/recon_multilayer.py
85 15 9
def main()
in ssl/real-dataset/main.py
80 22 1
def train()
in ssl/real-dataset/simclr_trainer.py
78 24 2
def run()
in student_specialization/recon_two_layer.py
67 14 1
def __init__()
in ssl/real-dataset/byol_trainer.py
65 7 9
def train()
in ssl/real-dataset/byol_trainer.py
61 19 2
def eval_model()
in ssl/real-dataset/linear_feature_eval.py
56 9 4
def optimize()
in luckmatter/recon_multilayer.py
55 12 7
def compute_w_minimal_space()
in ssl/real-dataset/byol_trainer.py
47 10 4
def init_dataset()
in student_specialization/dataset.py
47 7 1
def init_dataset()
in luckmatter/recon_multilayer.py
47 6 1
def optimize()
in student_specialization/recon_multilayer.py
42 12 9
def compute_Hs()
in luckmatter/recon_multilayer.py
41 7 4
def figure_success_rate()
in student_specialization/visualization/visualize.py
40 11 1
def forward()
in ssl/real-dataset/loss/nt_xent.py
37 6 4
def compute_w_corr()
in ssl/real-dataset/byol_trainer.py
36 13 2