facebookresearch / diplomacy_searchbot
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 867 units with 10,994 lines of code in units (16.1% of code).
    • 7 very long units (1,056 lines of code)
    • 25 long units (1,694 lines of code)
    • 108 medium size units (3,442 lines of code)
    • 158 small units (2,220 lines of code)
    • 569 very small units (2,582 lines of code)
9% | 15% | 31% | 20% | 23%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
py9% | 13% | 27% | 21% | 27%
cc12% | 19% | 39% | 17% | 11%
h0% | 14% | 32% | 19% | 32%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
dipcc/dipcc10% | 19% | 37% | 17% | 14%
fairdiplomacy/selfplay11% | 13% | 28% | 22% | 24%
fairdiplomacy/models20% | 8% | 34% | 19% | 16%
fairdiplomacy/agents16% | 12% | 19% | 17% | 33%
heyhi0% | 24% | 18% | 22% | 34%
fairdiplomacy/data0% | 18% | 43% | 19% | 18%
fairdiplomacy/utils0% | 9% | 25% | 21% | 44%
fairdiplomacy0% | 14% | 25% | 27% | 32%
conf/c02_sup_train0% | 0% | 77% | 0% | 22%
dipcc/python0% | 0% | 61% | 22% | 15%
conf/exps0% | 0% | 92% | 0% | 7%
ROOT0% | 0% | 0% | 62% | 37%
slurm0% | 0% | 0% | 42% | 57%
integration_tests0% | 0% | 0% | 0% | 100%
dipcc0% | 0% | 0% | 0% | 100%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
def do_step_research()
in fairdiplomacy/selfplay/exploit.py
230 32 4
def main_subproc()
in fairdiplomacy/models/diplomacy_model/train_sl.py
165 39 6
cc
GameState GameState::process_m()
in dipcc/dipcc/cc/adjudicator.cc
163 51 2
def get_orders()
in fairdiplomacy/agents/ce1p_agent.py
162 34 3
def do_step_policy_gradient()
in fairdiplomacy/selfplay/exploit.py
128 5 4
cc
bool _try_resolve_loc()
in dipcc/dipcc/cc/adjudicator.cc
105 30 3
cc
void GameState::load_all_possible_orders_m()
in dipcc/dipcc/cc/game_state.cc
103 30 0
cc
void encode_prev_orders()
in dipcc/dipcc/cc/encoding.cc
100 26 2
def _init_training_device_and_state()
in fairdiplomacy/selfplay/exploit.py
93 16 1
cc
int main()
in dipcc/dipcc/profiling/profile_late.cc
92 13 2
cc
void encode_board_state()
in dipcc/dipcc/cc/encoding.cc
89 26 2
cc
py::dict py_state_to_dict()
in dipcc/dipcc/pybind/py_dict.cc
88 24 1
def run_training_loop()
in fairdiplomacy/selfplay/exploit.py
78 13 1
def make_ratings_table()
in fairdiplomacy/data/build_metadata.py
72 23 1
def save_pandas_table()
in heyhi/gsheets.py
70 20 6
def get_datasets_from_cfg()
in fairdiplomacy/models/diplomacy_model/train_sl.py
68 19 1
def __call__()
in fairdiplomacy/selfplay/exploit.py
68 16 1
def maybe_launch_and_get_metrics()
in fairdiplomacy/utils/h2h_sweep.py
67 14 2
py::tuple ValidOrdersEncoder::encode_valid_orders()
in dipcc/dipcc/pybind/valid_orders_encoder.h
66 15 2
cc
json GameState::to_json()
in dipcc/dipcc/cc/game_state.cc
64 20 0