facebookresearch / torchbeast
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 135 units with 1,935 lines of code in units (65.7% of code).
    • 2 very long units (326 lines of code)
    • 4 long units (282 lines of code)
    • 17 medium size units (515 lines of code)
    • 29 small units (430 lines of code)
    • 83 very small units (382 lines of code)
16% | 14% | 26% | 22% | 19%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
py28% | 5% | 21% | 19% | 26%
cc0% | 47% | 24% | 18% | 9%
h0% | 0% | 51% | 38% | 9%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
torchbeast35% | 6% | 14% | 17% | 25%
src/cc0% | 43% | 31% | 16% | 8%
nest/nest0% | 0% | 42% | 45% | 11%
torchbeast/core0% | 0% | 42% | 22% | 34%
ROOT0% | 0% | 68% | 25% | 6%
nest0% | 0% | 0% | 73% | 26%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
def train()
in torchbeast/polybeast_learner.py
165 24 1
def train()
in torchbeast/monobeast.py
161 24 1
cc
void loop()
in src/cc/actorpool.cc
88 13 2
72 6 2
cc
void init_actorpool()
in src/cc/actorpool.cc
63 2 1
def __init__()
in torchbeast/polybeast_learner.py
59 5 3
return std::visit()
in nest/nest/nest.h
45 8 2
def forward()
in torchbeast/monobeast.py
41 6 3
def forward()
in torchbeast/polybeast_learner.py
41 6 3
static void for_each()
in nest/nest/nest.h
41 8 3
def gather_metadata()
in torchbeast/core/file_writer.py
33 8 0
cc
void enqueue()
in src/cc/actorpool.cc
33 9 1
def test()
in torchbeast/monobeast.py
32 5 2
cc
void set_outputs()
in src/cc/actorpool.cc
32 6 1
30 4 2
cc
static int aten_to_dtype()
in src/cc/actorpool.cc
26 10 1
Nest pack_as()
in nest/nest/nest.h
25 4 2
cc
TensorNest compute()
in src/cc/actorpool.cc
24 5 1
def log()
in torchbeast/core/file_writer.py
23 8 4
def __init__()
in torchbeast/atari_wrappers.py
23 4 6