microsoft / DirectML
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 1,301 units with 16,014 lines of code in units (63.6% of code).
    • 13 very long units (1,971 lines of code)
    • 24 long units (1,608 lines of code)
    • 151 medium size units (4,566 lines of code)
    • 230 small units (3,360 lines of code)
    • 883 very small units (4,509 lines of code)
12% | 10% | 28% | 20% | 28%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
py13% | 11% | 35% | 19% | 20%
cpp17% | 10% | 18% | 17% | 35%
h5% | 7% | 26% | 26% | 33%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
DxDispatch/src13% | 11% | 16% | 18% | 39%
PyTorch/yolov314% | 12% | 33% | 17% | 21%
Python/src14% | 5% | 16% | 25% | 37%
TensorFlow/squeezenet12% | 5% | 45% | 17% | 19%
TensorFlow/yolov318% | 16% | 29% | 30% | 5%
Libraries4% | 8% | 40% | 25% | 20%
PyTorch/classification0% | 36% | 26% | 7% | 28%
Python0% | 0% | 37% | 47% | 14%
PyTorch/torchvision_classification0% | 0% | 55% | 25% | 18%
TensorFlow/VisionTransformer0% | 0% | 0% | 15% | 84%
PyTorch/resnet500% | 0% | 0% | 48% | 51%
PyTorch/squeezenet0% | 0% | 0% | 48% | 51%
PyTorch/data0% | 0% | 0% | 0% | 100%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
def train()
in PyTorch/yolov3/train.py
301 130 4
def test()
in PyTorch/yolov3/test.py
200 89 13
def main()
in TensorFlow/yolov3/train.py
170 40 1
Model::DmlDispatchableDesc::BindPoints GetBindPoints()
in DxDispatch/src/model/JsonParsersGenerated.cpp
163 157 1
DML_OPERATOR_TYPE ParseDmlOperatorType()
in DxDispatch/src/model/JsonParsersGenerated.cpp
162 308 1
139 17 3
def _run()
in TensorFlow/squeezenet/src/train_squeezenet.py
130 19 1
129 30 2
def _create_parser()
in TensorFlow/squeezenet/src/squeezenet/arg_parsing.py
127 1 0
DXGI_FORMAT ParseDxgiFormat()
in DxDispatch/src/model/JsonParsers.cpp
125 234 1
void HlslDispatchable::Bind()
in DxDispatch/src/dxdispatch/HlslDispatchable.cpp
118 19 1
void Device::InitializeOperator()
in Python/src/device.cpp
105 11 2
inline GRUOutputs GRU()
in Libraries/DirectMLX.h
102 23 10
100 26 4
def detect()
in PyTorch/yolov3/detect.py
96 40 1
def __init__()
in PyTorch/yolov3/utils/datasets.py
86 32 13
def main()
in TensorFlow/yolov3/detect_video.py
85 4 1
void HlslDispatchable::CompileWithDxc()
in DxDispatch/src/dxdispatch/HlslDispatchable.cpp
83 6 0
void Executor::operator()
in DxDispatch/src/dxdispatch/Executor.cpp
78 12 0
76 11 1