facebookresearch / graph2nn
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 285 units with 2,709 lines of code in units (1.2% of code).
    • 1 very long units (137 lines of code)
    • 1 long units (56 lines of code)
    • 26 medium size units (755 lines of code)
    • 48 small units (713 lines of code)
    • 209 very small units (1,048 lines of code)
5% | 2% | 27% | 26% | 38%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
py5% | 2% | 27% | 26% | 38%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
tools49% | 0% | 36% | 9% | 4%
pycls/models0% | 4% | 28% | 23% | 44%
pycls/utils0% | 0% | 24% | 33% | 41%
pycls/datasets0% | 0% | 33% | 27% | 39%
ROOT0% | 0% | 0% | 69% | 30%
pycls0% | 0% | 0% | 65% | 35%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
def train_model()
in tools/train_net.py
137 64 3
def __init__()
in pycls/models/mobilenet.py
56 5 2
def __init__()
in pycls/models/vgg.py
49 5 2
def measure_layer()
in pycls/utils/metrics.py
45 8 2
def _construct_class()
in pycls/models/efficientnet.py
39 8 9
def generate_index()
in pycls/models/relation_graph.py
37 14 6
def flops_count()
in pycls/utils/metrics.py
36 12 1
def plot_error_curves_plotly()
in pycls/utils/plotting.py
36 6 4
def _construct_class()
in pycls/models/efficientnet.py
34 9 8
def random_crop()
in pycls/datasets/transforms.py
33 11 4
def random_sized_crop()
in pycls/datasets/transforms.py
32 8 3
def measure_model()
in pycls/utils/metrics.py
30 7 3
def _construct_class()
in pycls/models/resnet.py
30 2 7
def train_epoch()
in tools/train_net.py
29 4 10
def ws_graph()
in pycls/datasets/load_graph.py
26 12 4
def ws_graph()
in pycls/models/relation_graph.py
26 12 4
def single_proc_train()
in tools/train_net.py
25 10 0
def _construct_class()
in pycls/models/resnet.py
25 1 4
def eval_epoch()
in tools/train_net.py
24 5 8
def __init__()
in pycls/models/efficientnet.py
24 1 1