facebookresearch / worldsheet
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 1,645 units with 15,416 lines of code in units (61.7% of code).
    • 2 very long units (358 lines of code)
    • 14 long units (924 lines of code)
    • 156 medium size units (4,519 lines of code)
    • 296 small units (4,259 lines of code)
    • 1,177 very small units (5,356 lines of code)
2% | 5% | 29% | 27% | 34%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
py2% | 5% | 29% | 27% | 34%
c0% | 0% | 0% | 0% | 100%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
tools/sweeps70% | 0% | 6% | 16% | 6%
mmf/models0% | 14% | 31% | 22% | 31%
mmf/utils0% | 7% | 33% | 25% | 33%
mmf/datasets0% | 3% | 26% | 33% | 36%
mmf/trainers0% | 12% | 17% | 25% | 45%
mmf/modules0% | 0% | 24% | 36% | 39%
mmf/neural_rendering0% | 0% | 35% | 31% | 33%
tools/scripts0% | 0% | 66% | 9% | 23%
mmf_cli0% | 0% | 69% | 20% | 9%
mmf/common0% | 0% | 16% | 17% | 65%
ROOT0% | 0% | 0% | 18% | 81%
run_realestate10k0% | 0% | 0% | 0% | 100%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
def launch_train()
in tools/sweeps/lib/slurm.py
203 6 2
def get_args()
in tools/sweeps/lib/__init__.py
155 2 0
def forward()
in mmf/models/mmf_bert.py
88 18 2
def download()
in mmf/utils/download.py
79 27 5
def forward_losses()
in mmf/models/mesh_renderer.py
78 17 5
def save_forward_results()
in mmf/models/mesh_renderer.py
71 13 5
def run_training_epoch()
in mmf/trainers/core/training_loop.py
70 23 1
def build()
in mmf/models/mesh_renderer.py
69 13 1
def add_sample_details()
in mmf/datasets/builders/textvqa/dataset.py
65 19 3
def __getitem__()
in mmf/datasets/builders/synsin_realestate10k/realestate10k.py
65 6 2
def forward()
in mmf/models/lxmert.py
63 9 2
def _merge_with_dotlist()
in mmf/utils/configuration.py
58 18 3
def preprocess_sample()
in mmf/models/mmf_transformer.py
56 17 3
def forward()
in mmf/models/butd.py
55 7 2
def build_layers()
in mmf/models/mmf_transformer.py
54 4 1
def save()
in mmf/utils/checkpoint.py
53 11 4
def __call__()
in mmf/datasets/processors/processors.py
50 20 2
def convert()
in mmf_cli/hm_convert.py
50 10 1
def get_parser()
in tools/scripts/features/extract_features_vmb.py
48 1 1
def get_image_and_text_features()
in mmf/models/lxmert.py
48 8 3