facebookresearch / fastText
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 392 units with 4,656 lines of code in units (61.7% of code).
    • 2 very long units (256 lines of code)
    • 4 long units (271 lines of code)
    • 49 medium size units (1,447 lines of code)
    • 93 small units (1,374 lines of code)
    • 244 very small units (1,308 lines of code)
5% | 5% | 31% | 29% | 28%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
js33% | 0% | 18% | 9% | 38%
cc3% | 4% | 35% | 31% | 24%
py0% | 8% | 20% | 34% | 37%
cpp0% | 70% | 29% | 0% | 0%
h0% | 0% | 0% | 0% | 100%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
website/pages74% | 0% | 20% | 0% | 5%
src4% | 4% | 35% | 32% | 23%
alignment0% | 22% | 15% | 29% | 32%
scripts/kbcompletion0% | 70% | 29% | 0% | 0%
python/fasttext_module0% | 0% | 15% | 41% | 42%
crawl0% | 0% | 55% | 0% | 44%
ROOT0% | 0% | 42% | 18% | 38%
webassembly0% | 0% | 15% | 21% | 62%
python/benchmarks0% | 0% | 0% | 100% | 0%
website/static0% | 0% | 0% | 0% | 100%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
render()
in website/pages/en/index.js
129 3 0
cc
127 49 1
cc
void Autotune::train()
in src/autotune.cc
85 16 1
def align()
in alignment/unsup_multialign.py
68 27 4
int main()
in scripts/kbcompletion/eval.cpp
59 24 2
cc
59 14 1
cc
void ProductQuantizer::MStep()
in src/productquantizer.cc
46 10 5
cc
void test()
in src/main.cc
45 10 1
cc
45 12 2
cc
void FastText::quantize()
in src/fasttext.cc
44 8 2
43 9 1
42 8 1
render()
in website/pages/en/index.js
36 1 0
_train()
in webassembly/fasttext.js
36 5 4
cc
void predict()
in src/main.cc
36 10 1
cc
36 9 1
36 7 0
cc
void Dictionary::prune()
in src/dictionary.cc
35 9 1
34 9 1
cc
void Dictionary::load()
in src/dictionary.cc
33 5 1