facebookresearch / mtrl
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 324 units with 2,380 lines of code in units (36.6% of code).
    • 1 very long units (103 lines of code)
    • 3 long units (186 lines of code)
    • 15 medium size units (415 lines of code)
    • 27 small units (370 lines of code)
    • 278 very small units (1,306 lines of code)
4% | 7% | 17% | 15% | 54%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
py4% | 7% | 17% | 15% | 54%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
mtrl/experiment20% | 26% | 26% | 12% | 13%
mtrl0% | 16% | 26% | 23% | 32%
mtrl/agent0% | 0% | 13% | 13% | 73%
mtrl/utils0% | 0% | 21% | 8% | 69%
mtrl/env0% | 0% | 0% | 29% | 70%
mtrl/app0% | 0% | 0% | 100% | 0%
ROOT0% | 0% | 0% | 26% | 73%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
def run()
in mtrl/experiment/multitask.py
103 27 1
def __init__()
in mtrl/experiment/experiment.py
73 9 3
def evaluate_vec_env_of_tasks()
in mtrl/experiment/metaworld.py
61 7 4
def __init__()
in mtrl/logger.py
52 16 4
def evaluate_vec_env_of_tasks()
in mtrl/experiment/dmcontrol.py
41 6 4
def _create_dmcontrol_vec_envs_for_eval()
in mtrl/experiment/multitask.py
36 15 1
def collect_trajectory()
in mtrl/experiment/metaworld.py
33 8 3
def __init__()
in mtrl/agent/deepmdp.py
30 1 0
def __init__()
in mtrl/agent/hipbmdp.py
30 1 0
def _process_setup_config()
in mtrl/utils/config.py
28 11 1
def save()
in mtrl/replay_buffer.py
28 5 4
def load()
in mtrl/replay_buffer.py
28 6 2
def __init__()
in mtrl/agent/sac_ae.py
26 1 0
def _save_all()
in mtrl/replay_buffer.py
26 4 3
def forward()
in mtrl/agent/components/moe_layer.py
23 6 2
def _get_theta_sampling_strategy()
in mtrl/agent/hipbmdp.py
23 6 2
def load()
in mtrl/agent/abstract.py
21 6 3
def __init__()
in mtrl/agent/sac.py
21 1 0
def build_envs()
in mtrl/experiment/metaworld.py
21 3 1
def sample_action()
in mtrl/agent/distral.py
19 2 3