microsoft / perfview
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 11,826 units with 158,518 lines of code in units (57.7% of code).
    • 129 very long units (27,188 lines of code)
    • 299 long units (20,504 lines of code)
    • 1,178 medium size units (35,673 lines of code)
    • 2,370 small units (33,631 lines of code)
    • 7,850 very small units (41,522 lines of code)
17% | 12% | 22% | 21% | 26%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
cs17% | 12% | 22% | 21% | 26%
cpp0% | 26% | 12% | 40% | 20%
h0% | 0% | 0% | 12% | 87%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
src/PerfView26% | 19% | 26% | 15% | 12%
src/TraceEvent12% | 7% | 18% | 25% | 36%
src/HeapDump23% | 21% | 26% | 14% | 14%
src/CSVReader22% | 24% | 31% | 10% | 11%
src/TraceParserGen24% | 20% | 34% | 13% | 7%
src/EtwHeapDump78% | 0% | 13% | 4% | 3%
src/PerfViewExtensions29% | 17% | 21% | 24% | 6%
src/MemoryGraph6% | 24% | 29% | 20% | 19%
src/related5% | 28% | 35% | 16% | 14%
src/FastSerialization0% | 16% | 31% | 22% | 29%
src/EtwClrProfiler0% | 21% | 10% | 35% | 32%
src/Utilities0% | 13% | 39% | 20% | 26%
src/HeapDumpCommon0% | 0% | 100% | 0% | 0%
src/PerfView640% | 0% | 0% | 100% | 0%
src/PerfView.TestUtilities0% | 0% | 0% | 0% | 100%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
1546 209 5
public override SourceLocation SourceLocationForManagedCode()
in src/TraceEvent/Symbols/NativeSymbolModule.cs
1014 129 2
internal static void SetupCallbacks()
in src/TraceEvent/Computers/TraceManagedProcess.cs
1004 181 1
private unsafe void SetupCallbacks()
in src/TraceEvent/TraceLog.cs
636 96 1
private void ReadFile()
in src/PerfView/memory/ClrProfilerParser.cs
535 109 1
protected override void WriteHtmlBody()
in src/PerfView/PerfViewData.cs
524 64 4
public void Start()
in src/PerfView/CommandProcessor.cs
507 69 1
protected internal override void EnumerateTemplates()
in src/TraceEvent/Parsers/ApplicationServerTraceEventParser.cs
475 5 2
protected override void WriteHtmlBody()
in src/PerfView/PerfViewData.cs
417 50 4
protected override Action OpenImpl()
in src/PerfView/PerfViewData.cs
413 103 2
private unsafe void CopyRawEvents()
in src/TraceEvent/TraceLog.cs
409 80 2
public StartStopActivityComputer()
in src/TraceEvent/Computers/StartStopActivityComputer.cs
387 47 3
private static Dictionary InitEventMap()
in src/TraceEvent/Ctf/CtfTraceEventSource.cs
366 1 0
public static string GetManifestForRegisteredProvider()
in src/TraceEvent/RegisteredTraceEventParser.cs
357 66 1
internal void SetupCallbacks()
in src/EtwHeapDump/DotNetHeapDumpGraphReader.cs
355 70 4
protected internal override void EnumerateTemplates()
in src/TraceEvent/Parsers/Microsoft-Windows-TCPIP.cs
355 5 2
protected internal override void EnumerateTemplates()
in src/TraceEvent/Parsers/WpfTraceEventParser.cs
344 5 2
private void SetupCommandLine()
in src/PerfView/CommandLineArgs.cs
343 28 1
public static string ParsedArgsAsString()
in src/PerfView/CommandProcessor.cs
327 81 2
public static void ToHtml()
in src/PerfView/JitStats.cs
310 36 4