facebookresearch / ELF
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 1,594 units with 14,433 lines of code in units (68.9% of code).
    • 2 very long units (226 lines of code)
    • 17 long units (1,182 lines of code)
    • 145 medium size units (4,214 lines of code)
    • 263 small units (3,803 lines of code)
    • 1,167 very small units (5,008 lines of code)
1% | 8% | 29% | 26% | 34%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
cc4% | 15% | 35% | 24% | 20%
py0% | 5% | 29% | 32% | 32%
js0% | 20% | 41% | 21% | 16%
h0% | 0% | 17% | 20% | 62%
cpp0% | 0% | 68% | 31% | 0%
hh0% | 0% | 9% | 19% | 70%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
rts/engine3% | 7% | 30% | 20% | 37%
rts/game_MC8% | 11% | 23% | 20% | 36%
go0% | 17% | 33% | 25% | 22%
rts/backend0% | 26% | 33% | 15% | 25%
ROOT0% | 22% | 19% | 23% | 34%
rts/frontend0% | 20% | 41% | 21% | 16%
rts/game_CF0% | 10% | 22% | 33% | 33%
elf0% | 2% | 24% | 25% | 47%
rlpytorch0% | 0% | 50% | 15% | 33%
atari0% | 0% | 47% | 29% | 23%
elf_python0% | 0% | 19% | 41% | 39%
rlpytorch/methods0% | 0% | 35% | 48% | 15%
rlpytorch/runner0% | 0% | 32% | 50% | 16%
rts/game_TD0% | 0% | 22% | 22% | 54%
rlpytorch/utils0% | 0% | 23% | 26% | 50%
elf/lib0% | 0% | 40% | 28% | 30%
rlpytorch/sampler0% | 0% | 37% | 51% | 10%
rlpytorch/trainer0% | 0% | 13% | 48% | 38%
rlpytorch/stats0% | 0% | 0% | 20% | 79%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
cc
bool MCRuleActor::ActByState()
in rts/game_MC/mc_rule_actor.cc
113 31 4
cc
bool Player::PathPlanning()
in rts/engine/player.cc
113 30 8
cc
bool RuleActor::act_per_unit()
in rts/engine/rule_actor.cc
89 44 6
def prompt()
in df_console.py
87 28 3
86 27 4
cc
int main()
in rts/backend/main_loop.cc
85 12 2
cc
void MCExtractor::extract()
in rts/game_MC/state_feature.cc
82 22 4
def update()
in rts/game_MC/actor_critic_changed.py
75 15 4
cc
RawMsgStatus RawToCmd::Process()
in rts/backend/raw2cmd.cc
75 31 5
cc
void VerifyBoard()
in go/board.cc
73 19 1
65 24 3
cc
bool Play()
in go/board.cc
63 16 2
cc
bool RTSMap::GenerateTDMaze()
in rts/engine/map.cc
62 21 1
cc
61 22 2
var render = function()
in rts/frontend/game.js
60 13 1
56 10 2
def _init_collectors()
in elf/utils_elf.py
55 10 6
def initialize()
in go/game.py
54 6 1
cc
void Preload::collect_stats()
in rts/engine/rule_actor.cc
54 14 3
50 19 2