facebookresearch / off-belief-learning
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 811 units with 8,672 lines of code in units (65.1% of code).
    • 2 very long units (278 lines of code)
    • 22 long units (1,483 lines of code)
    • 76 medium size units (2,418 lines of code)
    • 131 small units (1,861 lines of code)
    • 580 very small units (2,632 lines of code)
3% | 17% | 27% | 21% | 30%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
py5% | 11% | 33% | 20% | 27%
cc0% | 27% | 23% | 22% | 27%
h0% | 10% | 14% | 23% | 51%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
pyhanabi/tools22% | 9% | 37% | 19% | 10%
hanabi-learning-environment/hanabi_lib0% | 31% | 21% | 22% | 25%
rlcc0% | 41% | 19% | 16% | 21%
hanabi-learning-environment0% | 12% | 10% | 17% | 58%
pyhanabi0% | 11% | 48% | 15% | 24%
hanabi-learning-environment/agents/rainbow0% | 15% | 28% | 33% | 22%
rela0% | 5% | 33% | 28% | 32%
pyhanabi/common_utils0% | 0% | 10% | 26% | 62%
hanabi-learning-environment/agents0% | 0% | 65% | 0% | 34%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
def extract_game()
in pyhanabi/tools/extract_human_data.py
163 57 2
def parse_new_log()
in pyhanabi/tools/parse_log.py
115 36 2
cc
int EncodeLastAction_()
in hanabi-learning-environment/hanabi_lib/canonical_encoders.cc
98 24 7
cc
void R2D2Actor::act()
in rlcc/r2d2_actor.cc
90 20 2
def create_rl_context()
in pyhanabi/train_belief.py
88 10 1
cc
int EncodeV0Belief_()
in hanabi-learning-environment/hanabi_lib/canonical_encoders.cc
86 12 9
def __init__()
in hanabi-learning-environment/agents/rainbow/dqn_agent.py
77 4 22
cc
73 7 1
def __init__()
in hanabi-learning-environment/agents/rainbow/replay_memory.py
72 8 10
def make()
in hanabi-learning-environment/rl_env.py
70 7 3
cc
void DataGenLoop::mainLoop()
in rlcc/clone_data_generator.cc
69 14 0
def parse_args()
in pyhanabi/selfplay.py
66 2 0
def run_game()
in hanabi-learning-environment/game_example.py
65 5 1
def run_game()
in pyhanabi/tools/run_game.py
64 14 4
cc
void HanabiState::ApplyMove()
in hanabi-learning-environment/hanabi_lib/hanabi_state.cc
61 11 1
cc
61 7 8
cc
std::vector CanonicalObservationEncoder::EncodeARV0Belief()
in hanabi-learning-environment/hanabi_lib/canonical_encoders.cc
60 6 4
cc
int EncodeCardKnowledge()
in hanabi-learning-environment/hanabi_lib/canonical_encoders.cc
58 13 7
cc
int EncodeHands()
in hanabi-learning-environment/hanabi_lib/canonical_encoders.cc
57 10 8
virtual void mainLoop()
in rlcc/thread_loop.h
56 19 0