microsoft / LightGBM
Conditional Complexity

The distribution of complexity of units (measured with McCabe index).

Intro
  • Conditional complexity (also called cyclomatic complexity) is a term used to measure the complexity of software. The term refers to the number of possible paths through a program function. A higher value ofter means higher maintenance and testing costs (infosecinstitute.com).
  • Conditional complexity is calculated by counting all conditions in the program that can affect the execution path (e.g. if statement, loops, switches, and/or operators, try and catch blocks...).
  • Conditional complexity is measured at the unit level (methods, functions...).
  • Units are classified in four categories based on the measured McCabe index: 1-5 (simple units), 6-10 (medium complex units), 11-25 (complex units), 26+ (very complex units).
Learn more...
Conditional Complexity Overall
  • There are 1,732 units with 27,602 lines of code in units (58.6% of code).
    • 2 very complex units (386 lines of code)
    • 22 complex units (2,701 lines of code)
    • 104 medium complex units (6,297 lines of code)
    • 188 simple units (5,831 lines of code)
    • 1,416 very simple units (12,387 lines of code)
1% | 9% | 22% | 21% | 44%
Legend:
51+
26-50
11-25
6-10
1-5
Alternative Visuals
Conditional Complexity per Extension
51+
26-50
11-25
6-10
1-5
cpp2% | 12% | 28% | 18% | 37%
hpp0% | 9% | 17% | 25% | 47%
py0% | 9% | 22% | 17% | 50%
h0% | 1% | 10% | 23% | 64%
R0% | 0% | 17% | 33% | 48%
Conditional Complexity per Logical Component
primary logical decomposition
51+
26-50
11-25
6-10
1-5
src/treelearner4% | 14% | 23% | 24% | 32%
src/io1% | 17% | 23% | 22% | 34%
python-package/lightgbm0% | 9% | 23% | 17% | 48%
src/boosting0% | 9% | 41% | 16% | 32%
src0% | 5% | 23% | 11% | 59%
include/LightGBM0% | 1% | 8% | 24% | 64%
src/metric0% | 0% | 35% | 26% | 37%
src/network0% | 0% | 27% | 13% | 59%
src/objective0% | 0% | 13% | 39% | 47%
src/application0% | 0% | 50% | 9% | 39%
R-package/R0% | 0% | 17% | 33% | 48%
R-package/src0% | 0% | 4% | 3% | 92%
python-package0% | 0% | 0% | 19% | 80%
helpers0% | 0% | 0% | 0% | 100%
swig0% | 0% | 0% | 0% | 100%
Most Complex Units
Top 20 most complex units
Unit# linesMcCabe index# params
void GPUTreeLearner::AllocateGPUMemory()
in src/treelearner/gpu_tree_learner.cpp
272 54 0
114 53 0
def early_stopping()
in python-package/lightgbm/callback.py
111 47 5
void LinearTreeLearner::CalculateLinear()
in src/treelearner/linear_tree_learner.cpp
192 47 5
114 45 2
def _lazy_init()
in python-package/lightgbm/basic.py
95 44 11
inline std::string ParseMetricAlias()
in include/LightGBM/config.h
29 43 1
void BinMapper::FindBin()
in src/io/bin.cpp
173 43 11
bool GBDT::LoadModelFromString()
in src/boosting/gbdt_model_text.cpp
187 41 2
void FindBestThresholdSequentially()
in src/treelearner/feature_histogram.hpp
191 40 8
void Metadata::CheckOrPartition()
in src/io/metadata.cpp
130 39 2
void DatasetLoader::SetHeader()
in src/io/dataset_loader.cpp
142 37 1
void FindBestThresholdCategoricalInner()
in src/treelearner/feature_histogram.hpp
214 37 6
170 35 5
data_size_t SplitInner()
in src/io/dense_bin.hpp
79 35 10
data_size_t SplitInner()
in src/io/sparse_bin.hpp
80 35 10
inline std::string ParseObjectiveAlias()
in include/LightGBM/config.h
26 34 1
void TrainingShareStates::CalcBinOffsets()
in src/io/train_share_states.cpp
135 31 3
void Dataset::AddFeaturesFrom()
in src/io/dataset.cpp
149 29 1
def add_features_from()
in python-package/lightgbm/basic.py
74 28 2