facebookresearch / transformer-sequential
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 149 units with 1,907 lines of code in units (82.6% of code).
    • 2 very long units (302 lines of code)
    • 1 long units (58 lines of code)
    • 17 medium size units (487 lines of code)
    • 39 small units (574 lines of code)
    • 90 very small units (486 lines of code)
15% | 3% | 25% | 30% | 25%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
py15% | 3% | 25% | 30% | 25%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
ROOT56% | 0% | 8% | 19% | 15%
models0% | 6% | 25% | 41% | 25%
utils0% | 0% | 58% | 0% | 41%
modules0% | 0% | 35% | 22% | 42%
data0% | 0% | 39% | 37% | 23%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
def main()
in main.py
158 27 1
144 1 0
def forward()
in models/expire_span.py
58 10 4
def step()
in utils/logger.py
49 4 6
def add_args()
in models/expire_span.py
34 1 1
def forward()
in models/expire_span.py
34 4 4
def generate_sample()
in data/gen_data_collisions.py
34 5 2
def cache_initprocess()
in models/feedback.py
33 11 2
def add_args()
in modules/adaptive_span.py
31 1 1
def forward()
in models/feedback.py
30 6 4
def forward()
in models/expire_span.py
27 2 6
def trim_memory()
in modules/adaptive_span.py
27 10 5
def forward()
in models/compressive.py
26 1 6
def forward()
in models/compressive.py
26 3 4
25 6 5
def save()
in utils/checkpoint.py
23 7 5
def forward()
in models/transformer_seq.py
23 3 4
def load()
in utils/checkpoint.py
22 6 5
def gen_data()
in data/gen_data_collisions.py
22 4 3
def tokenize()
in data.py
21 6 2