facebookresearch / faiss
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,306 units with 33,434 lines of code in units (46.0% of code).
    • 24 very long units (3,431 lines of code)
    • 111 long units (7,317 lines of code)
    • 315 medium size units (9,543 lines of code)
    • 444 small units (6,455 lines of code)
    • 1,412 very small units (6,688 lines of code)
10% | 21% | 28% | 19% | 20%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
cpp11% | 24% | 29% | 19% | 15%
py8% | 15% | 31% | 19% | 24%
c0% | 95% | 0% | 0% | 4%
h0% | 2% | 16% | 21% | 59%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
faiss17% | 30% | 24% | 13% | 13%
faiss/impl8% | 19% | 38% | 18% | 14%
faiss/utils5% | 11% | 32% | 22% | 28%
contrib17% | 13% | 27% | 13% | 27%
faiss/python16% | 19% | 20% | 22% | 21%
faiss/gpu8% | 35% | 13% | 21% | 21%
tutorial/cpp0% | 100% | 0% | 0% | 0%
benchs/bench_all_ivf0% | 44% | 28% | 18% | 8%
faiss/invlists0% | 12% | 28% | 30% | 29%
benchs/distributed_ondisk0% | 10% | 35% | 18% | 36%
c_api/gpu0% | 21% | 6% | 20% | 50%
c_api0% | 6% | 0% | 50% | 43%
benchs0% | 6% | 50% | 27% | 15%
benchs/link_and_code0% | 0% | 41% | 33% | 24%
c_api/impl0% | 0% | 0% | 47% | 52%
c_api/utils0% | 0% | 0% | 16% | 83%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
void write_index()
in faiss/impl/index_write.cpp
249 38 2
def handle_torch_Index()
in contrib/torch_utils.py
247 40 1
void Clustering::train_encoded()
in faiss/Clustering.cpp
227 42 5
203 38 10
void OPQMatrix::train()
in faiss/VectorTransform.cpp
183 20 2
void ResidualQuantizer::train()
in faiss/impl/ResidualQuantizer.cpp
150 24 2
void IndexIVFPQFastScan::search_implem_12()
in faiss/IndexIVFPQFastScan.cpp
148 24 8
def handle_Index()
in faiss/python/__init__.py
147 18 1
std::unique_ptr index_factory_sub()
in faiss/index_factory.cpp
146 21 3
145 23 8
void PCAMatrix::train()
in faiss/VectorTransform.cpp
136 31 2
void quantize_LUT_and_bias()
in faiss/utils/quantize_lut.cpp
135 22 11
void ITQMatrix::train()
in faiss/VectorTransform.cpp
127 9 2
117 29 9
void ParameterSpace::explore()
in faiss/AutoTune.cpp
117 25 5
void beam_search_encode_step()
in faiss/impl/ResidualQuantizer.cpp
112 13 13
void IndexHNSW2Level::search()
in faiss/IndexHNSW.cpp
110 15 5
108 19 5
106 17 5
int main()
in faiss/gpu/perf/PerfIVFPQAdd.cpp
105 13 2