microsoft / DirectX-Graphics-Samples
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 4,383 units with 60,448 lines of code in units (2.8% of code).
    • 75 very long units (13,224 lines of code)
    • 145 long units (9,702 lines of code)
    • 465 medium size units (14,501 lines of code)
    • 701 small units (10,104 lines of code)
    • 2,997 very small units (12,917 lines of code)
21% | 16% | 23% | 16% | 21%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
cpp23% | 19% | 31% | 15% | 9%
hpp32% | 17% | 15% | 11% | 22%
h12% | 7% | 13% | 22% | 43%
inl0% | 22% | 19% | 21% | 36%
py0% | 0% | 25% | 33% | 40%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
MiniEngine/Model37% | 20% | 15% | 10% | 16%
Libraries/D3DX12AffinityLayer16% | 7% | 31% | 23% | 20%
MiniEngine/Core16% | 16% | 21% | 16% | 28%
Libraries/D3D12RaytracingFallback15% | 19% | 26% | 14% | 23%
TechniqueDemos/D3D12MemoryManagement24% | 18% | 21% | 18% | 17%
MiniEngine/ModelConverter53% | 15% | 17% | 7% | 6%
Libraries/D3DX12Residency17% | 24% | 17% | 20% | 18%
Tools/DXGIAdapterRemovalSupportTest19% | 21% | 30% | 17% | 12%
MiniEngine/Tools22% | 16% | 30% | 13% | 17%
MiniEngine/ModelViewer0% | 31% | 37% | 5% | 25%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
void CStateObjectInfo::ResolveSubobjectAssociations()
in Libraries/D3D12RaytracingFallback/src/StateObjectProcessing.cpp
566 142 0
token_type scan_string()
in MiniEngine/Model/json.hpp
488 212 0
bool parse_cbor_internal()
in MiniEngine/Model/json.hpp
383 233 2
bool parse_msgpack_internal()
in MiniEngine/Model/json.hpp
339 273 0
void CStateObjectInfo::AddCollection()
in Libraries/D3D12RaytracingFallback/src/StateObjectProcessing.cpp
328 60 1
void OptimizeMesh()
in MiniEngine/Model/MeshConvert.cpp
319 57 3
token_type scan_number()
in MiniEngine/Model/json.hpp
266 98 0
HRESULT DX12Framework::LoadMip()
in TechniqueDemos/D3D12MemoryManagement/src/Framework.cpp
264 25 2
void write_cbor()
in MiniEngine/Model/json.hpp
263 50 1
class __declspec()
in Libraries/D3DX12AffinityLayer/Desktop/CD3DX12AffinityDevice.h
260 1 1
class __declspec()
in Libraries/D3DX12AffinityLayer/UWP/CD3DX12AffinityDevice.h
260 1 1
HRESULT DX12Framework::CreateDeviceDependentStateInternal()
in TechniqueDemos/D3D12MemoryManagement/src/Framework.cpp
260 34 0
void write_msgpack()
in MiniEngine/Model/json.hpp
258 56 1
bool AssimpModel::LoadAssimp()
in MiniEngine/ModelConverter/ModelAssimp.cpp
236 14 1
void dump()
in MiniEngine/Model/json.hpp
221 30 5
class __declspec()
in Libraries/D3DX12AffinityLayer/Desktop/CD3DX12AffinityGraphicsCommandList.h
217 1 1
class __declspec()
in Libraries/D3DX12AffinityLayer/UWP/CD3DX12AffinityGraphicsCommandList.h
217 1 1
void KbmBuildKeyMapping()
in MiniEngine/Core/GameInput.cpp
215 1 0
bool sax_parse_internal()
in MiniEngine/Model/json.hpp
205 41 1
void dump_escaped()
in MiniEngine/Model/json.hpp
194 28 2