facebookresearch / unlikelihood_training
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 60 units with 1,251 lines of code in units (90.7% of code).
    • 2 very long units (301 lines of code)
    • 2 long units (110 lines of code)
    • 12 medium size units (391 lines of code)
    • 21 small units (320 lines of code)
    • 23 very small units (129 lines of code)
24% | 8% | 31% | 25% | 10%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
py24% | 8% | 31% | 25% | 10%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
custom/gpt248% | 0% | 18% | 29% | 2%
custom14% | 12% | 35% | 23% | 13%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
def main()
in custom/gpt2/run_gpt2.py
166 34 0
def main()
in custom/evaluation.py
135 18 0
def ranking_metrics()
in custom/metrics.py
55 1 7
def get_metric()
in custom/report_metrics.py
55 10 2
def forward()
in custom/candidate_penalty_ce_loss.py
50 5 5
def load()
in custom/evaluate_utils.py
45 12 5
def eval_single_token_prediction()
in custom/evaluate_utils.py
44 2 5
def eval_singletoken()
in custom/gpt2/run_gpt2.py
35 3 4
def aggregate_and_normalize()
in custom/metrics.py
34 23 1
def forward()
in custom/sequence_penalty_loss.py
34 6 5
def generate_completions()
in custom/evaluate_utils.py
31 9 11
def ul_seq()
in custom/gpt2/run_gpt2.py
29 4 3
def forward()
in custom/baseline_cross_entropy.py
26 5 5
def _forward_one()
in custom/sequence_generator.py
21 7 8
def print_metrics()
in custom/report_metrics.py
21 8 2
def main()
in custom/report_metrics.py
21 6 0
def aggregate_logging_outputs()
in custom/candidate_penalty_ce_loss.py
20 11 1
def aggregate_logging_outputs()
in custom/sequence_penalty_loss.py
20 11 1
def train_step()
in custom/language_modeling_with_generation.py
19 9 6
def sample_sequence()
in custom/gpt2/run_gpt2.py
19 4 6