microsoft / DirectXShaderCompiler
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 64,848 units with 815,703 lines of code in units (55.6% of code).
    • 917 very long units (166,040 lines of code)
    • 2,084 long units (143,199 lines of code)
    • 6,453 medium size units (201,557 lines of code)
    • 8,300 small units (121,070 lines of code)
    • 47,094 very small units (183,837 lines of code)
20% | 17% | 24% | 14% | 22%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
cpp22% | 20% | 27% | 15% | 14%
c32% | 22% | 25% | 9% | 10%
py25% | 10% | 23% | 15% | 25%
cs29% | 10% | 25% | 14% | 20%
h<1% | 2% | 7% | 11% | 77%
inl33% | 21% | 17% | 18% | 8%
inc8% | 12% | 31% | 21% | 24%
cc4% | 4% | 33% | 31% | 27%
pl52% | 0% | 31% | 6% | 10%
js0% | 0% | 23% | 37% | 39%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
tools/clang21% | 17% | 24% | 14% | 22%
lib/CodeGen21% | 22% | 29% | 15% | 11%
lib/Transforms22% | 24% | 29% | 13% | 9%
lib/HLSL25% | 23% | 27% | 13% | 9%
projects/dxilconv48% | 10% | 17% | 9% | 13%
utils/TableGen28% | 21% | 24% | 12% | 13%
lib/Bitcode53% | 11% | 14% | 12% | 8%
lib/Analysis17% | 19% | 28% | 14% | 18%
tools/llvm-objdump40% | 25% | 22% | 7% | 4%
lib/MC19% | 17% | 24% | 16% | 21%
lib/IR14% | 8% | 20% | 19% | 36%
utils/hct37% | 11% | 17% | 15% | 17%
lib/Miniz42% | 18% | 23% | 6% | 8%
lib/Support10% | 15% | 29% | 20% | 24%
lib/DxcSupport55% | 0% | 14% | 16% | 13%
lib/AsmParser22% | 20% | 28% | 19% | 8%
lib/ExecutionEngine14% | 18% | 32% | 16% | 18%
lib/DxilPIXPasses27% | 22% | 29% | 11% | 9%
lib/DXIL9% | 12% | 26% | 22% | 28%
include/dxc7% | 4% | 8% | 14% | 64%
lib/DebugInfo16% | 9% | 21% | 16% | 36%
lib/Object12% | 11% | 19% | 22% | 34%
lib/DxilContainer30% | 17% | 19% | 18% | 13%
utils/lit22% | 4% | 34% | 13% | 25%
include/llvm1% | 1% | 9% | 12% | 75%
tools/llvm-nm45% | 18% | 26% | 3% | 6%
tools/llvm-cxxdump73% | 0% | 9% | 12% | 4%
lib/DxcBindingTable80% | 0% | 14% | 3% | 1%
lib/DxilRootSignature19% | 39% | 18% | 10% | 11%
tools/llvm-size47% | 40% | 10% | 0% | 2%
tools/llvm-readobj6% | 15% | 29% | 28% | 19%
tools/llvm-bcanalyzer80% | 0% | 11% | 4% | 3%
tools/opt52% | 0% | 20% | 14% | 11%
utils34% | 22% | 13% | 8% | 20%
lib/DxrFallback7% | 15% | 24% | 21% | 30%
utils/KillTheDoctor61% | 0% | 27% | 0% | 10%
tools/lli20% | 0% | 34% | 31% | 14%
tools/llvm-config67% | 0% | 22% | 7% | 1%
tools/yaml2obj20% | 23% | 35% | 8% | 11%
utils/PerfectShuffle59% | 0% | 11% | 11% | 17%
tools/llvm-extract100% | 0% | 0% | 0% | 0%
tools/llvm-mc33% | 32% | 19% | 11% | 3%
tools/llc85% | 0% | 14% | 0% | 0%
unittests/IR29% | 0% | 6% | 3% | 60%
lib/Linker12% | 36% | 20% | 16% | 13%
tools/llvm-pdbdump11% | 26% | 29% | 13% | 18%
tools/dsymutil7% | 17% | 44% | 12% | 17%
tools/llvm-cov12% | 37% | 23% | 7% | 19%
tools/llvm-diff16% | 14% | 23% | 30% | 14%
tools/llvm-lto75% | 0% | 0% | 24% | 0%
utils/FileCheck14% | 36% | 28% | 14% | 6%
lib/DxilDia0% | 16% | 18% | 20% | 44%
utils/unittest0% | 2% | 25% | 27% | 44%
lib/TableGen0% | 14% | 40% | 24% | 19%
lib/ProfileData0% | 19% | 34% | 23% | 23%
tools/llvm-rtdyld0% | 61% | 20% | 7% | 9%
tools/obj2yaml0% | 35% | 44% | 14% | 6%
tools/dxexp0% | 90% | 0% | 0% | 9%
lib/Target0% | 12% | 27% | 22% | 37%
utils/llvm-build0% | 12% | 33% | 17% | 36%
lib/Fuzzer0% | 7% | 24% | 32% | 35%
utils/release0% | 35% | 64% | 0% | 0%
tools/llvm-stress0% | 18% | 36% | 26% | 18%
tools/llvm-c-test0% | 14% | 48% | 27% | 9%
tools/llvm-dis0% | 47% | 29% | 12% | 10%
lib/LTO0% | 8% | 57% | 19% | 15%
tools/llvm-mcmarkup0% | 45% | 0% | 33% | 21%
tools/llvm-symbolizer0% | 0% | 60% | 25% | 13%
tools/llvm-profdata0% | 0% | 89% | 7% | 3%
lib/Option0% | 0% | 45% | 26% | 28%
tools/verify-uselistorder0% | 0% | 53% | 16% | 29%
tools/macho-dump0% | 0% | 62% | 30% | 7%
lib/Passes0% | 0% | 57% | 21% | 20%
utils/yaml-bench0% | 0% | 70% | 29% | 0%
unittests/Analysis0% | 0% | 77% | 22% | 0%
tools/llvm-as0% | 0% | 100% | 0% | 0%
unittests/Support0% | 0% | 10% | 23% | 66%
utils/testgen0% | 0% | 86% | 0% | 13%
unittests/Transforms0% | 0% | 38% | 12% | 49%
unittests/ADT0% | 0% | 8% | 9% | 82%
unittests/DebugInfo0% | 0% | 32% | 0% | 67%
utils/lint0% | 0% | 36% | 0% | 63%
utils/not0% | 0% | 100% | 0% | 0%
tools/llvm-link0% | 0% | 44% | 55% | 0%
utils/count0% | 0% | 100% | 0% | 0%
unittests/Linker0% | 0% | 96% | 0% | 4%
lib/MSSupport0% | 0% | 0% | 16% | 83%
lib/IRReader0% | 0% | 0% | 100% | 0%
utils/version0% | 0% | 0% | 41% | 58%
tools/lto0% | 0% | 0% | 15% | 84%
unittests/ProfileData0% | 0% | 0% | 21% | 78%
tools/llvm-dwarfdump0% | 0% | 0% | 48% | 51%
lib/PassPrinters0% | 0% | 0% | 15% | 84%
unittests/Bitcode0% | 0% | 0% | 32% | 67%
include/llvm-c0% | 0% | 0% | 0% | 100%
utils/fpcmp0% | 0% | 0% | 0% | 100%
unittests/CodeGen0% | 0% | 0% | 0% | 100%
unittests/MC0% | 0% | 0% | 0% | 100%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
void DxbcConverter::ConvertInstructions()
in projects/dxilconv/lib/DxbcConverter/DxbcConverter.cpp
1864 457 1
void Clang::ConstructJob()
in tools/clang/lib/Driver/Tools.cpp
1487 522 6
RValue CodeGenFunction::EmitBuiltinExpr()
in tools/clang/lib/CodeGen/CGBuiltin.cpp
1341 405 4
def populate_dxil_operations()
in utils/hct/hctdb.py
1211 30 1
void SelectionDAGLegalize::ExpandNode()
in lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
1042 237 1
static HRESULT CodePageBufferToUtf8()
in lib/DxcSupport/FileIOHelper.cpp
944 174 6
void CGMSHLSLRuntime::AddHLSLFunctionInfo()
in tools/clang/lib/CodeGen/CGHLSLMS.cpp
942 234 2
std::error_code BitcodeReader::parseFunctionBody()
in lib/Bitcode/Reader/BitcodeReader.cpp
935 327 1
bool FunctionAttrs::inferPrototypeAttributes()
in lib/Transforms/IPO/FunctionAttrs.cpp
833 384 1
private void InitializeComponent()
in tools/clang/tools/dotnetc/EditorForm.Designer.cs
773 1 0
void Parser::ParseDeclarationSpecifiers()
in tools/clang/lib/Parse/ParseDecl.cpp
747 293 5
int ReadDxcOpts()
in lib/DxcSupport/HLSLOptions.cpp
652 217 5
void DxbcConverter::AnalyzeShader()
in projects/dxilconv/lib/DxbcConverter/DxbcConverter.cpp
603 122 1
void CXXNameMangler::mangleExpression()
in tools/clang/lib/AST/ItaniumMangle.cpp
590 184 2
ExprResult Parser::ParseCastExpression()
in tools/clang/lib/Parse/ParseExpr.cpp
568 241 4
bool Lexer::LexTokenInternal()
in tools/clang/lib/Lex/Lexer.cpp
552 261 2
void DxbcConverter::LoadOperand()
in projects/dxilconv/lib/DxbcConverter/DxbcConverter.cpp
549 101 5
bool TargetLowering::SimplifyDemandedBits()
in lib/CodeGen/SelectionDAG/TargetLowering.cpp
545 165 6
static void AddObjCKeyValueCompletions()
in tools/clang/lib/Sema/SemaCodeComplete.cpp
532 124 6
HRESULT STDMETHODCALLTYPE Compile()
in tools/clang/tools/dxcompiler/dxcompilerobj.cpp
513 106 2