apple / coremltools
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 3,342 units with 43,361 lines of code in units (59.7% of code).
    • 29 very long units (4,428 lines of code)
    • 122 long units (8,369 lines of code)
    • 417 medium size units (13,001 lines of code)
    • 528 small units (7,807 lines of code)
    • 2,246 very small units (9,756 lines of code)
10% | 19% | 29% | 18% | 22%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
py7% | 18% | 30% | 19% | 24%
cpp21% | 22% | 27% | 12% | 16%
hpp0% | 7% | 29% | 38% | 23%
mm0% | 0% | 42% | 42% | 15%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
mlmodel/src20% | 22% | 28% | 13% | 15%
coremltools/converters6% | 20% | 30% | 18% | 23%
coremltools/models9% | 10% | 31% | 21% | 27%
coremlpython0% | 0% | 42% | 42% | 15%
modelpackage/src0% | 0% | 15% | 34% | 50%
mlmodel/tools0% | 0% | 37% | 43% | 19%
milstoragepython0% | 0% | 0% | 0% | 100%
coremltools/_deps0% | 0% | 0% | 0% | 100%
scripts0% | 0% | 0% | 0% | 100%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
def _quantize_nn_spec()
in coremltools/models/neural_network/quantization_utils.py
345 45 4
Result NeuralNetworkSpecValidator::validateLayer()
in mlmodel/src/Validation/NeuralNetwork/NeuralNetworkValidator.cpp
299 160 1
Result validateFeatureDescription()
in mlmodel/src/Validation/InterfaceValidators.cpp
271 86 3
Result validate()
in mlmodel/src/Validation/NonMaximumSuppressionValidator.cpp
250 78 1
def functionalize_loops()
in coremltools/converters/mil/frontend/tensorflow/tf_graph_pass/functionalize_loops.py
243 72 3
def load()
in coremltools/converters/mil/backend/mil/load.py
185 56 4
Result validateNeuralNetworkTopLevel()
in mlmodel/src/Validation/NeuralNetwork/NeuralNetworkValidator.cpp
165 63 4
def lstm()
in coremltools/converters/mil/backend/nn/op_mapping.py
152 26 3
void ItemSimilarityRecommender::finish()
in mlmodel/src/transforms/ItemSimilarityRecommender.cpp
149 22 0
def conv_helper()
in coremltools/converters/mil/backend/nn/op_mapping.py
134 32 3
def lstm()
in coremltools/converters/mil/frontend/torch/ops.py
132 32 2
Result NeuralNetworkSpecValidator::validateConvolution3DLayer()
in mlmodel/src/Validation/NeuralNetwork/NeuralNetworkLayerValidator.cpp
131 28 1
void NeuralNetworkShaper::shapeSliceLayer()
in mlmodel/src/Validation/NeuralNetwork/NeuralNetworkShapes.cpp
128 16 1
def StridedSlice()
in coremltools/converters/mil/frontend/tensorflow/ops.py
127 42 2
void NeuralNetworkShaper::ProcessLayer()
in mlmodel/src/Validation/NeuralNetwork/NeuralNetworkShapes.cpp
127 42 1
def batch_norm()
in coremltools/converters/mil/frontend/torch/ops.py
124 33 2
Result validate()
in mlmodel/src/Validation/WordTaggerValidator.cpp
124 37 1
Result NeuralNetworkSpecValidator::validateConvolutionLayer()
in mlmodel/src/Validation/NeuralNetwork/NeuralNetworkLayerValidator.cpp
123 39 1
def _get_conv_params()
in coremltools/converters/onnx/_operators.py
119 36 6
def remove_redundant_transposes()
in coremltools/converters/mil/backend/nn/passes/mlmodel_passes.py
117 39 1