microsoft / dotnet-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 365 units with 5,942 lines of code in units (75.0% of code).
    • 3 very long units (428 lines of code)
    • 13 long units (855 lines of code)
    • 73 medium size units (2,347 lines of code)
    • 85 small units (1,294 lines of code)
    • 191 very small units (1,018 lines of code)
7% | 14% | 39% | 21% | 17%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
cs7% | 14% | 39% | 21% | 17%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
WinForms-HDPI/PerMonitorAware33% | 13% | 24% | 3% | 25%
WinForms-HDPI/SystemAware22% | 32% | 13% | 7% | 24%
System.Numerics/SIMD/Mandelbrot8% | 8% | 60% | 10% | 12%
Microsoft.Diagnostics.Tracing/TraceEvent/TraceEvent0% | 30% | 42% | 16% | 9%
System.Reflection.Metadata/MdDumper/Visualization0% | 6% | 35% | 45% | 12%
System.Numerics/SIMD/RayTracer0% | 0% | 37% | 31% | 30%
Microsoft.Diagnostics.Tracing/EventSource/EventSource0% | 0% | 22% | 63% | 14%
System.Reflection.Metadata/MdDumper0% | 0% | 84% | 0% | 15%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
private void InitializeComponent()
in WinForms-HDPI/PerMonitorAware/SimpleLayout.Designer.cs
158 1 0
private void InitializeComponent()
in WinForms-HDPI/SystemAware/MenuStripAndCheckedListBox.Designer.cs
153 1 0
public static Render SelectRender()
in System.Numerics/SIMD/Mandelbrot/Interfaces.cs
117 27 7
private void InitializeComponent()
in WinForms-HDPI/SystemAware/MainForm.Designer.cs
93 1 0
public static void Run()
in Microsoft.Diagnostics.Tracing/TraceEvent/TraceEvent/41_TraceLogMonitor.cs
81 5 0
public static void Run()
in Microsoft.Diagnostics.Tracing/TraceEvent/TraceEvent/51_SimpleMonitorRelogger.cs
78 7 0
private void InitializeComponent()
in WinForms-HDPI/SystemAware/MultipleScalingPasses.Designer.cs
72 1 0
public static void Run()
in Microsoft.Diagnostics.Tracing/TraceEvent/TraceEvent/33_KernelAndClrMonitorWin7.cs
70 2 0
public static int Run()
in Microsoft.Diagnostics.Tracing/TraceEvent/TraceEvent/10_SimpleEventSourceMonitor.cs
64 5 0
private void InitializeComponent()
in WinForms-HDPI/PerMonitorAware/MainForm.Designer.cs
64 1 0
private void InitializeComponent()
in WinForms-HDPI/SystemAware/DataGridViewHeadersScaling.Designer.cs
58 1 0
private void DrawMandelbrot()
in System.Numerics/SIMD/Mandelbrot/FlyThru.xaml.cs
57 6 2
public static void Run()
in Microsoft.Diagnostics.Tracing/TraceEvent/TraceEvent/31_KernelAndClrMonitor.cs
56 5 0
private void DrawMandelbrot()
in System.Numerics/SIMD/Mandelbrot/MainWindow.xaml.cs
56 10 2
public static void Run()
in Microsoft.Diagnostics.Tracing/TraceEvent/TraceEvent/21_ObserveJitEvents.cs
54 4 0
private void WriteRows()
in System.Reflection.Metadata/MdDumper/Visualization/MetadataVisualizer.cs
52 8 1
private Color CalculateRecursiveColor()
in System.Numerics/SIMD/RayTracer/Camera.cs
50 10 3
public static void Run()
in Microsoft.Diagnostics.Tracing/TraceEvent/TraceEvent/20_ObserveGCEvent.cs
48 2 0
public static void Run()
in Microsoft.Diagnostics.Tracing/TraceEvent/TraceEvent/30_MonitorLoads.cs
48 2 0
private void InitializeComponent()
in WinForms-HDPI/SystemAware/RightAnchor.Designer.cs
47 1 0