facebookresearch / OnlineAttacks
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 221 units with 2,247 lines of code in units (53.9% of code).
    • 2 very long units (268 lines of code)
    • 5 long units (349 lines of code)
    • 17 medium size units (510 lines of code)
    • 22 small units (328 lines of code)
    • 175 very small units (792 lines of code)
11% | 15% | 22% | 14% | 35%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
py11% | 15% | 22% | 14% | 35%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
online_attacks/classifiers/cifar29% | 0% | 20% | 12% | 36%
online_attacks/experiments33% | 35% | 24% | 6% | 0%
online_attacks/scripts0% | 43% | 19% | 17% | 19%
online_attacks/utils/optimizer0% | 47% | 0% | 28% | 24%
online_attacks/classifiers0% | 0% | 71% | 0% | 28%
online_attacks/online_algorithms0% | 0% | 32% | 21% | 45%
online_attacks/classifiers/madry0% | 0% | 51% | 20% | 27%
online_attacks/attacks0% | 0% | 71% | 0% | 28%
online_attacks/datastream0% | 0% | 18% | 13% | 67%
online_attacks/classifiers/mnist0% | 0% | 0% | 25% | 74%
online_attacks0% | 0% | 0% | 33% | 66%
online_attacks/utils0% | 0% | 0% | 8% | 91%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
def train()
in online_attacks/classifiers/cifar/models/wide_resnet.py
149 19 2
def main()
in online_attacks/experiments/mnist_online.py
119 4 2
def eval_comp_ratio()
in online_attacks/scripts/eval_all.py
98 10 4
def main()
in online_attacks/experiments/stochastic_toy.py
68 7 0
def step()
in online_attacks/utils/optimizer/sls/sls.py
66 13 2
def main()
in online_attacks/experiments/toy.py
59 7 0
def compute_hist()
in online_attacks/scripts/compute_hist_all.py
58 9 4
def load_madry_model()
in online_attacks/classifiers/madry/__init__.py
45 5 3
def run()
in online_attacks/scripts/train_classifiers.py
39 12 2
def test()
in online_attacks/classifiers/trainer.py
39 7 2
def train()
in online_attacks/classifiers/trainer.py
36 6 2
def make_pgd_attacker()
in online_attacks/attacks/pgd.py
35 4 2
def __init__()
in online_attacks/classifiers/cifar/models/googlenet.py
32 1 8
def create_argument_parser()
in online_attacks/scripts/train_classifiers.py
31 4 0
def run_experiment()
in online_attacks/experiments/stochastic_toy.py
29 6 3
def run_experiment()
in online_attacks/experiments/hyper_search_stochastic_toy.py
29 5 3
def run_experiment()
in online_attacks/experiments/toy.py
28 5 3
def __init__()
in online_attacks/datastream/toy_data.py
25 5 4
def action()
in online_attacks/online_algorithms/stochastic_virtual.py
25 12 3
def __init__()
in online_attacks/classifiers/cifar/models/densenet.py
24 1 6