neo-ai / treelite
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 429 units with 5,162 lines of code in units (55.1% of code).
    • 3 very long units (482 lines of code)
    • 9 long units (618 lines of code)
    • 55 medium size units (1,808 lines of code)
    • 56 small units (817 lines of code)
    • 306 very small units (1,437 lines of code)
9% | 11% | 35% | 15% | 27%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
cc18% | 21% | 29% | 10% | 19%
py0% | 4% | 45% | 18% | 31%
h0% | 0% | 25% | 29% | 45%
java0% | 0% | 61% | 11% | 27%
cpp0% | 0% | 0% | 0% | 100%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
src/frontend55% | 10% | 17% | 1% | 14%
src/compiler0% | 43% | 28% | 11% | 15%
python/treelite0% | 5% | 37% | 23% | 33%
runtime/native0% | 0% | 55% | 15% | 28%
runtime/java0% | 0% | 54% | 10% | 35%
src/c_api0% | 0% | 34% | 23% | 42%
src/common0% | 0% | 72% | 17% | 10%
src0% | 0% | 84% | 0% | 15%
include/treelite0% | 0% | 6% | 37% | 56%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
inline treelite::Model ParseStream()
in src/frontend/lightgbm.cc
255 53 1
Model LoadProtobufModel()
in src/frontend/protobuf.cc
125 14 1
inline treelite::Model ParseStream()
in src/frontend/xgboost.cc
102 17 1
CompiledModel Compile()
in src/compiler/failsafe.cc
91 12 1
void ExportProtobufModel()
in src/frontend/protobuf.cc
88 12 2
void HandleCodeFolderNode()
in src/compiler/ast_native.cc
79 9 3
void FormatArrayAsELF()
in src/compiler/elf/elf_formatter.cc
66 2 1
CompiledModel Compile()
in src/compiler/ast_native.cc
61 9 1
void HandleQNode()
in src/compiler/ast_native.cc
60 11 3
def _create_shared_base()
in python/treelite/contrib/util.py
60 16 4
void HandleMainNode()
in src/compiler/ast_native.cc
59 6 3
bool fold_code()
in src/compiler/ast/fold_code.cc
54 15 3
def predict_instance()
in runtime/native/python/treelite_runtime/predictor.py
50 20 4
def generate_makefile()
in python/treelite/contrib/__init__.py
50 17 4
def _varsall_bat_path()
in python/treelite/contrib/msvc.py
49 20 0
public Predictor()
in runtime/java/treelite4j/src/main/java/ml/dmlc/treelite4j/Predictor.java
48 9 3
inline void SetAffinity()
in runtime/native/src/thread_pool/thread_pool.h
47 5 0
def create_shared()
in python/treelite/contrib/__init__.py
45 16 5
def __init__()
in runtime/native/python/treelite_runtime/predictor.py
43 5 4
42 6 5