| Tool | Category / Purpose | What Problem It Solves | Why Use This Tool (Key Strengths) | When to Use (Training/Capstone Flow) |
|---|---|---|---|---|
| dotnet-counters | Live runtime diagnostics | Check CPU, GC, allocations, thread pool health | Lightweight, real-time, safe for production | Baseline analysis → during load test (k6) |
| dotTrace | CPU profiling | Identify slow functions, hot paths, loops, LINQ, EF hotspots | Best UI, deep code-level insight, widely used | After load → find hot paths & optimize |
| dotMemory | Memory profiling | Detect leaks, excessive allocations, LOH pressure | Best-in-class memory graphs & retention analysis | Before/after optimization → memory validation |
| dotnet-trace | Runtime event tracing | Capture GC, JIT, Kestrel, exceptions, EF events | Low overhead, works with PerfView | For deep investigation or converting trace into PerfView |
| dotnet-gcdump | Heap snapshotting | See object counts, sizes, leaked objects | Safe in production, simple heap capture | When memory leak or steadily growing heap suspected |
| PerfView | Deep CPU + GC + allocation analysis | Low-level .NET internals analysis | The “truth machine”; industry standard for internals | Validate final optimizations → GC & CPU deep dive |
| BenchmarkDotNet | Micro-benchmarks | Compare LINQ vs loops, serializers, algorithms | Official .NET benchmarking standard | Benchmark isolated methods before optimization |
| PerfMon | OS-level performance | CPU, disk, memory, network baselines | Excellent for historical baselining | Before load test → during load → after load |
| Windows Resource Monitor | Quick triage | Identify per-process CPU, disk, memory hotspots | Very visual, instant insights | Initial troubleshooting before deeper profiling |
| Visual Studio Profiler (Optional) | Basic built-in profiler | Quick look at CPU/memory without external tools | Beginner-friendly, no install needed | Quick local checks before dotTrace/dotMemory |
📘 MASTERING .NET PERFORMANCE TOOLING (2025 EDITION)
A Complete End-to-End Guide for Developers, SREs & Performance Engineers
1. dotnet-counters
Recommended Title:
“dotnet-counters: Real-Time Diagnostics for .NET Applications”
dotnet-counters is a lightweight, real-time performance monitoring tool built into the .NET SDK. It provides immediate feedback on CPU usage, GC behavior, thread pool saturation, allocations, and ASP.NET Core request metrics.
1.1 Why dotnet-counters?
- Minimal overhead → safe to use in production.
- Works locally, in containers, and in Windows/Linux servers.
- Captures live health signals:
- CPU
- GC Heap Size
- Gen 0/1/2 Collections
- Allocations/sec
- ThreadPool queues/threads
- Kestrel request metrics
- Ideal for first responder diagnostics.
1.2 Install
Already included in .NET 6+.
To update:
dotnet tool update -g dotnet-counters
1.3 Common Commands
List running .NET processes
dotnet-counters ps
Real-time monitoring
dotnet-counters monitor --process-id 1234
Filter by provider
dotnet-counters monitor --process-id 1234 System.Runtime
Code language: CSS (css)
Collect 60-second metrics snapshot
dotnet-counters collect --process-id 1234 --duration 60 --output counters.json
Code language: CSS (css)
1.4 Key Metrics to Watch
- CPU %: >70% sustained = CPU pressure.
- GC Heap Size continuously growing → memory leak suspicion.
- Gen 2 collections too frequent → LOH pressure.
- ThreadPool Queue Length rising → request overload.
- Requests/sec vs Failures/sec for ASP.NET Core apps.
1.5 Practical Use Case
- You run k6 load test.
- dotnet-counters shows:
- High allocations
- Many Gen 2 collections
- You investigate using dotMemory/PerfView.
2. JetBrains dotTrace
Recommended Title:
“dotTrace: CPU Profiling & Hot Path Analysis for .NET”
dotTrace is the most widely adopted profiler for .NET. It helps locate slow functions, high CPU usage, blocking calls, inefficient LINQ queries, and expensive EF queries.
2.1 Why dotTrace?
- Extremely intuitive UI.
- Supports:
- Sampling
- Tracing
- Line-by-line performance
- Shows call trees, flame graphs, and hot paths.
- Works brilliantly with ASP.NET Core apps under real traffic.
2.2 How to Profile an Application
- Open dotTrace.
- Choose “Profile .NET Application”.
- Select your executable or attach to running process.
- Select profiling mode:
- Sampling → fastest for CPU
- Timeline → holistic
- Generate load on target app (browser or k6).
- Stop session.
- Analyze “Hot Spots.”
2.3 What to Look For
- Methods with high inclusive time.
- Excessive LINQ allocations.
- Repeated EF queries (N+1 pattern).
- Lock/contention hotspots.
2.4 Common Optimizations Identified
- Add AsNoTracking() to EF queries.
- Replace LINQ with optimized loops.
- Avoid unnecessary AutoMapper mappings.
- Cache repeated DB queries.
3. JetBrains dotMemory
Recommended Title:
“dotMemory: Memory Leak Detection & Allocation Optimization”
dotMemory is the gold-standard memory profiler for .NET, used to identify leaks, excessive allocations, LOH problems, and object retention paths.
3.1 Why dotMemory?
- Detects:
- Memory leaks
- Unbounded collections
- LOH pressure
- Excessive allocations
- Visualizes object graphs & references.
3.2 Typical Workflow
- Start dotMemory.
- Attach to your app.
- Generate load.
- Take memory snapshot.
- Locate:
- Largest object types
- LOH usage
- Retention paths
3.3 Key Indicators
- Growing heap → leak or caching bug.
- LargeObjectHeap (LOH): large arrays, strings, JSON deserialization.
- Unreleased static fields retaining objects.
3.4 Why It’s Essential
Most performance issues are not CPU—they are allocation pressure causing GC storms.
4. dotnet-trace
Recommended Title:
“dotnet-trace: Deep Runtime Event Tracing Using EventPipe”
dotnet-trace captures low-level runtime events:
- GC
- JIT
- ThreadPool
- Exceptions
- Kestrel
- EF Core
- ASP.NET Core metrics
- Custom
EventSourcelogs
4.1 Record a trace
dotnet-trace collect --process-id 1234 --output trace.nettrace
Code language: CSS (css)
4.2 Analyze With
- PerfView
- Visual Studio
- SpeedScope
4.3 When to Use
- Investigating:
- GC pauses
- Excessive exceptions
- ThreadPool starvation
- Slow EF queries
5. dotnet-gcdump
Recommended Title:
“dotnet-gcdump: Lightweight Heap Dump Capture for .NET”
dotnet-gcdump captures a heap snapshot without needing a full process dump.
5.1 Capture dump
dotnet-gcdump collect --process-id 1234 --output dump.gcdump
Code language: CSS (css)
5.2 Open in PerfView or Visual Studio
Useful when:
- Memory leak suspected
- High memory usage in production
- You want to inspect object counts and sizes
Low overhead → safe for production.
6. PerfView
Recommended Title:
“PerfView: The Ultimate .NET GC & CPU Investigation Tool”
PerfView is created by Vance Morrison, .NET Architect.
It is the authoritative tool for low-level analysis.
6.1 Why PerfView?
- Deep GC analysis.
- Allocation tracking.
- CPU sampling.
- Thread & blocking visualization.
- Understands ETW/EventPipe trace logs.
6.2 Typical Workflow
- Open PerfView.
- Collect → CPU, GC, Allocations.
- Generate load.
- Analyze:
- CallTree (CPU hotspots)
- GCStats (GC cycles, pause time)
- Events (GC/AllocationTick)
PerfView is the truth machine—it confirms all findings discovered via dotTrace/dotMemory.
7. BenchmarkDotNet
Recommended Title:
“BenchmarkDotNet: Microbenchmarking & Code Optimization Framework”
BenchmarkDotNet is used by Microsoft teams and OSS maintainers.
7.1 Why BenchmarkDotNet?
- Scientific, controlled measurement
- Warmup + multiple iterations
- GC + allocations metrics
- Helps decide:
- LINQ vs loop
- Regex vs manual parsing
- JSON serializers
7.2 Example Benchmark
[MemoryDiagnoser]
public class MyBench
{
[Benchmark]
public int UsingLinq() => Enumerable.Range(1,100000).Where(x => x%2==0).Count();
[Benchmark]
public int UsingFor()
{
int c = 0;
for(int i=1;i<=100000;i++)
if(i%2==0) c++;
return c;
}
}
Code language: PHP (php)
Run:
dotnet run -c Release
Outputs:
- Mean execution time
- Std deviation
- Allocations
7.3 Why It’s Essential
You cannot optimize code blindly.
BenchmarkDotNet gives repeatable, measurable results.
8. Windows Performance Monitor (PerfMon)
Recommended Title:
“PerfMon: Windows OS-Level Metrics & Capacity Baselines”
PerfMon is the traditional Windows tool to record processor, memory, disk, and network metrics over time.
8.1 Why PerfMon?
- Provides historical logs
- Lightweight
- Excellent for baseline creation
- Combines OS + .NET counters
8.2 Useful Counters
CPU
- Processor → % Processor Time
- .NET CLR → % Time in GC
Memory
- Available MB
- Pages/sec
Disk
- Avg Disk sec/Read
- Avg Disk sec/Write
Network
- Bytes Total/sec
ASP.NET Core
- If using hosting bundle: request rate, queue length
8.3 Use Cases
- Detecting machine-level bottlenecks
- Correlating app slowdown with CPU/Disk spikes
- Long-term trending for capacity planning
9. Windows Resource Monitor
Recommended Title:
“Resource Monitor: Quick Process-Level Diagnostics in Windows”
Resource Monitor is a more visual tool than PerfMon, ideal for quick triage.
9.1 Tabs to Use
- CPU → per-thread CPU usage
- Memory → working sets, faults
- Disk → processes causing heavy I/O
- Network → active connections and bandwidth
9.2 When to Use
- When you need fast visual confirmation of:
- Which process is consuming CPU
- Which process is hitting disk
- Whether the machine is I/O bound
Use Resource Monitor for triage → then deeper tools (PerfView, dotTrace).
10. Visual Studio Profiler (Optional)
Recommended Title:
“Visual Studio Profiler: Fast, Built-In Performance Analysis”
VS Profiler is a baseline CPU and memory profiler included with Visual Studio.
10.1 Pros
- No install
- Easy to use
- Good for newcomers
10.2 Cons
- Less powerful than dotTrace/dotMemory
- No advanced investigation capabilities
- Not ideal for complex performance labs
10.3 When to Use
- Early learning modules
- Quick local CPU profiling
- Initial “smoke test” before deeper analysis
✅ Final Recommendation for Your Capstone
Use ALL tools above, but categorize like this:
Primary Tools
- dotnet-counters
- dotTrace
- dotMemory
- PerfView
- BenchmarkDotNet
Supporting Tools
- dotnet-trace
- dotnet-gcdump
- PerfMon
- Resource Monitor
Optional
- Visual Studio Profiler
This mapping gives a complete, world-class performance engineering toolkit aligned with modern .NET practices used by top companies and training programs.
📘 Category Overview Table (Tool-by-Tool Classification)
| Category | Primary Tools | Supporting Tools | Optional Tools |
|---|---|---|---|
| Live Monitoring | dotnet-counters | PerfMon, Resource Monitor | – |
| CPU Profiling | dotTrace | PerfView (advanced CPU) | Visual Studio Profiler |
| Memory Profiling | dotMemory | dotnet-gcdump, PerfView allocations | Visual Studio Profiler |
| Deep Runtime Internals | PerfView | dotnet-trace | – |
| Microbenchmarking | BenchmarkDotNet | – | – |
| Production Diagnostics | dotnet-counters, dotnet-gcdump | PerfView | – |
🛠️ Training Use Case Alignment Table
| Scenario / Problem | Best Tool | Secondary Tools | Outcome |
|---|---|---|---|
| High CPU under load | dotTrace | PerfView | Identify hot methods, inefficient loops, expensive LINQ |
| Memory leaking or growing | dotMemory | dotnet-gcdump, PerfView | Find retention paths, static caches, LOH pressure |
| ThreadPool starvation | dotnet-counters | dotnet-trace | Solve slow request handling / blocked threads |
| Excessive allocations | dotMemory | PerfView allocations | Reduce pressure → fewer GCs → better latency |
| Slow API endpoints | dotTrace | PerfView, dotnet-counters | Optimize EF queries, caching, business logic |
| Poor GC performance | PerfView | dotnet-counters | Reduce Gen2 GCs, lower pause time |
| Compare algorithm performance | BenchmarkDotNet | – | Measure LINQ vs loops, serializers, sorting algos |
| OS bottlenecks (disk, CPU, memory) | PerfMon | Resource Monitor | Capacity planning, environment tuning |
| Quick triage on Windows | Resource Monitor | PerfMon | Identify which process is causing trouble |
| Fast “first look” profiling | Visual Studio Profiler | dotTrace | Quick smoke test of performance |
I’m a DevOps/SRE/DevSecOps/Cloud Expert passionate about sharing knowledge and experiences. I have worked at Cotocus. I share tech blog at DevOps School, travel stories at Holiday Landmark, stock market tips at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow , and SEO strategies at Wizbrand.
Do you want to learn Quantum Computing?
Please find my social handles as below;
Rajesh Kumar Personal Website
Rajesh Kumar at YOUTUBE
Rajesh Kumar at INSTAGRAM
Rajesh Kumar at X
Rajesh Kumar at FACEBOOK
Rajesh Kumar at LINKEDIN
Rajesh Kumar at WIZBRAND