facebookresearch / pycls
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 351 units with 3,141 lines of code in units (49.3% of code).
    • 0 very long units (0 lines of code)
    • 3 long units (203 lines of code)
    • 21 medium size units (650 lines of code)
    • 70 small units (982 lines of code)
    • 257 very small units (1,306 lines of code)
0% | 6% | 20% | 31% | 41%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
py0% | 6% | 20% | 31% | 41%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
tools0% | 36% | 47% | 3% | 13%
pycls/core0% | 6% | 24% | 36% | 31%
pycls/sweep0% | 0% | 28% | 32% | 38%
pycls/models0% | 0% | 7% | 32% | 60%
dev0% | 0% | 46% | 23% | 29%
pycls/datasets0% | 0% | 0% | 46% | 53%
ROOT0% | 0% | 0% | 0% | 100%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
def sweep_analyze()
in tools/sweep_analyze.py
74 38 0
def plot_error_curves_plotly()
in pycls/core/plotting.py
67 6 4
def main()
in tools/sweep_launch_job.py
62 11 0
def sweep_launch()
in tools/sweep_launch.py
50 9 0
def plot_models()
in pycls/sweep/plotting.py
47 21 4
def plot_curves()
in pycls/sweep/plotting.py
43 23 5
def sweep_setup()
in tools/sweep_setup.py
41 18 0
def construct_optimizer()
in pycls/core/optimizer.py
38 14 1
def train_model()
in pycls/core/trainer.py
37 14 0
def sweep_collect()
in tools/sweep_collect.py
34 18 0
def multi_proc_run()
in pycls/core/distributed.py
33 8 2
def save_checkpoint()
in pycls/core/checkpoint.py
31 9 6
def train_epoch()
in pycls/core/trainer.py
29 7 8
def compute_time_train()
in pycls/core/benchmark.py
28 9 2
def scale_model()
in pycls/models/scaler.py
28 15 0
def init_weights_vit()
in pycls/models/vit.py
28 15 1
def sample_cfgs()
in tools/sweep_setup.py
26 18 1
def main()
in tools/run_net.py
25 6 0
def compute_time_full()
in pycls/core/benchmark.py
24 1 4
def plot_trends()
in pycls/sweep/plotting.py
23 8 5