facebookresearch / beanmachine
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 2,664 units with 20,074 lines of code in units (57.2% of code).
    • 3 very long units (389 lines of code)
    • 27 long units (1,868 lines of code)
    • 154 medium size units (4,531 lines of code)
    • 334 small units (4,657 lines of code)
    • 2,146 very small units (8,629 lines of code)
1% | 9% | 22% | 23% | 42%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
cpp4% | 9% | 27% | 31% | 27%
py1% | 9% | 21% | 20% | 47%
h0% | 0% | 9% | 2% | 88%
js0% | 0% | 0% | 46% | 53%
pyi0% | 0% | 0% | 0% | 100%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
src/beanmachine/graph3% | 8% | 24% | 28% | 33%
src/beanmachine/tutorials11% | 32% | 33% | 9% | 12%
src/beanmachine/ppl0% | 6% | 17% | 21% | 53%
scripts0% | 68% | 0% | 14% | 16%
src/beanmachine/applications0% | 7% | 51% | 22% | 19%
sphinx/source0% | 0% | 64% | 26% | 9%
website/src/pages0% | 0% | 0% | 100% | 0%
website0% | 0% | 0% | 0% | 100%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
def log_plot_comparison()
in src/beanmachine/tutorials/utils/radon.py
150 5 2
void Graph::cavi()
in src/beanmachine/graph/cavi.cpp
123 28 4
void Graph::gibbs()
in src/beanmachine/graph/gibbs.cpp
116 27 3
def _lookup()
in src/beanmachine/ppl/compiler/bmg_types.py
96 2 0
def floor_plot()
in src/beanmachine/tutorials/utils/radon.py
96 3 1
def plot_partial_pooling_model()
in src/beanmachine/tutorials/utils/baseball.py
92 2 2
def _transform()
in src/beanmachine/tutorials/utils/nba.py
90 13 1
def uranium()
in src/beanmachine/tutorials/utils/radon.py
86 1 2
std::unique_ptr Distribution::new_distribution()
in src/beanmachine/graph/distribution/distribution.cpp
83 19 3
def transform_notebook()
in scripts/convert_ipynb_to_mdx.py
79 20 2
def propose()
in src/beanmachine/ppl/legacy/inference/proposer/single_site_no_u_turn_sampler_proposer.py
79 14 3
void Distribution::sample()
in src/beanmachine/graph/distribution/distribution.cpp
76 22 2
NutsProposer::Tree NutsProposer::build_tree()
in src/beanmachine/graph/global/proposer/nuts_proposer.cpp
76 6 8
void Graph::_produce_performance_report()
in src/beanmachine/graph/perf_report.cpp
73 10 3
def update_graph()
in src/beanmachine/ppl/legacy/world/world.py
68 22 2
double NutsProposer::propose()
in src/beanmachine/graph/global/proposer/nuts_proposer.cpp
68 7 2
std::string op()
in src/beanmachine/graph/to_dot.cpp
63 31 1
def plot_value_counts()
in src/beanmachine/tutorials/utils/hearts.py
63 4 1
def block_propose_change()
in src/beanmachine/ppl/legacy/inference/abstract_mh_infer.py
61 11 2
std::string NodeValue::to_string()
in src/beanmachine/graph/graph.cpp
61 20 0