facebookresearch / MathsFromExamples
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 125 units with 3,311 lines of code in units (91.5% of code).
    • 5 very long units (862 lines of code)
    • 12 long units (919 lines of code)
    • 25 medium size units (785 lines of code)
    • 30 small units (452 lines of code)
    • 53 very small units (293 lines of code)
26% | 27% | 23% | 13% | 8%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
py26% | 27% | 23% | 13% | 8%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
src/envs32% | 27% | 11% | 18% | 9%
src15% | 30% | 34% | 11% | 7%
ROOT84% | 0% | 15% | 0% | 0%
src/model0% | 36% | 33% | 11% | 18%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
def get_parser()
in train.py
213 1 0
def enc_dec_step_beam_fast()
in src/evaluator.py
213 51 5
def register_args()
in src/envs/ode.py
166 1 1
def gen_control()
in src/envs/ode.py
136 43 3
def __init__()
in src/envs/ode.py
134 14 2
def __init__()
in src/trainer.py
100 37 4
def enc_dec_step()
in src/evaluator.py
99 15 4
93 37 2
def generate_beam()
in src/model/transformer.py
84 38 7
80 16 1
def gen_control_t()
in src/envs/ode.py
79 11 1
def gen_fourier_cond_init()
in src/envs/ode.py
77 14 1
def generate_cond_init()
in src/envs/ode.py
70 15 5
def check_hypothesis()
in src/evaluator.py
64 22 1
def get_optimizer()
in src/optim.py
61 15 2
def __init__()
in src/envs/ode.py
57 36 7
def fwd()
in src/model/transformer.py
55 17 8
def check_gramian()
in src/evaluator.py
50 15 4
def compare_gramians()
in src/evaluator.py
46 20 5
def forward()
in src/model/transformer.py
43 13 5