facebookresearch / FAMBench
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 764 units with 11,883 lines of code in units (65.4% of code).
    • 12 very long units (2,584 lines of code)
    • 21 long units (1,482 lines of code)
    • 108 medium size units (3,468 lines of code)
    • 141 small units (2,076 lines of code)
    • 482 very small units (2,273 lines of code)
21% | 12% | 29% | 17% | 19%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
py23% | 10% | 29% | 18% | 18%
cc21% | 18% | 29% | 14% | 16%
cpp0% | 44% | 12% | 16% | 26%
h0% | 0% | 22% | 17% | 59%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
benchmarks/dlrm/ootb35% | 8% | 30% | 14% | 10%
benchmarks/rnnt/ootb/inference12% | 16% | 28% | 18% | 23%
benchmarks/rnnt/ootb/train19% | 9% | 27% | 20% | 23%
benchmarks/dlrm/ootb/tools37% | 18% | 40% | 3% | 0%
benchmarks/dlrm/ubench0% | 93% | 0% | 0% | 6%
benchmarks/cudnn_multihead_attn0% | 0% | 88% | 0% | 11%
benchmarks/dlrm/ootb/tricks0% | 0% | 47% | 37% | 15%
benchmarks/dlrm/ootb/optim0% | 0% | 65% | 24% | 10%
benchmarks/xlmr/ootb0% | 0% | 22% | 51% | 25%
fb5logging0% | 0% | 12% | 25% | 62%
bmlogging0% | 0% | 0% | 0% | 100%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
def run()
in benchmarks/dlrm/ootb/dlrm_s_pytorch.py
971 117 0
def main()
in benchmarks/rnnt/ootb/train/train.py
335 71 0
cc
void IssueQueryController::IssueQueriesInternal()
in benchmarks/rnnt/ootb/inference/loadgen/issue_query_controller.cc
163 25 2
def main()
in benchmarks/rnnt/ootb/train/inference.py
143 40 0
def make_criteo_data_and_loaders()
in benchmarks/dlrm/ootb/dlrm_data_pytorch.py
135 10 2
def adagrad_optimizer()
in benchmarks/dlrm/ootb/dlrm_s_caffe2.py
129 33 8
cc
PerformanceResult IssueQueries()
in benchmarks/rnnt/ootb/inference/loadgen/loadgen.cc
124 10 4
cc
void PerformanceSummary::LogSummary()
in benchmarks/rnnt/ootb/inference/loadgen/loadgen.cc
123 25 1
def init_distributed()
in benchmarks/dlrm/ootb/extend_distributed.py
122 33 5
cc
void FindPeakPerformanceMode()
in benchmarks/rnnt/ootb/inference/loadgen/loadgen.cc
117 5 4
def visualize_umap_data()
in benchmarks/dlrm/ootb/tools/visualize.py
117 1 17
def visualize_all_data_umap()
in benchmarks/dlrm/ootb/tools/visualize.py
105 4 6
cc
std::vector GenerateQueries()
in benchmarks/rnnt/ootb/inference/loadgen/loadgen.cc
97 25 4
def parse_args()
in benchmarks/rnnt/ootb/train/train.py
92 1 0
cc
void PerformanceSummary::LogDetail()
in benchmarks/rnnt/ootb/inference/loadgen/loadgen.cc
90 17 1
def run_emb()
in benchmarks/dlrm/ubench/dlrm_ubench_train_embeddingbag_driver.py
85 14 2
cc
void RunPerformanceMode()
in benchmarks/rnnt/ootb/inference/loadgen/loadgen.cc
82 7 4
cc
void StartTest()
in benchmarks/rnnt/ootb/inference/loadgen/loadgen.cc
81 8 4
int main()
in benchmarks/rnnt/ootb/inference/loadgen/benchmark/repro.cpp
77 11 2
def main()
in benchmarks/dlrm/ubench/dlrm_ubench_comms_driver.py
76 19 0