
Performance Optimization
Profiling, BenchmarkDotNet, memory allocation, boxing/unboxing, Span<T>, performance best practices
1What is the main advantage of BenchmarkDotNet over a simple Stopwatch for measuring performance?
What is the main advantage of BenchmarkDotNet over a simple Stopwatch for measuring performance?
Відповідь
BenchmarkDotNet performs warm-ups, measures multiple iterations with statistical stabilization, avoids JIT and GC biases. A simple Stopwatch can give unrepresentative results as it doesn't control these factors. BenchmarkDotNet also provides detailed metrics like memory allocations per operation.
2Which Microsoft tool is recommended for analyzing memory allocations and identifying memory leaks in production?
Which Microsoft tool is recommended for analyzing memory allocations and identifying memory leaks in production?
Відповідь
dotMemory from JetBrains and PerfView from Microsoft are recommended tools for profiling memory in .NET. PerfView is free, open-source and can analyze heap allocations, stack traces and GC events. It is particularly suitable for diagnosing memory leaks in production without significant overhead.
3How to identify hidden memory allocations in a LINQ method like FirstOrDefault()?
How to identify hidden memory allocations in a LINQ method like FirstOrDefault()?
Відповідь
Using BenchmarkDotNet with MemoryDiagnoser attribute shows allocations per operation. LINQ lambdas create hidden allocations via delegates. Replacing with a simple foreach loop eliminates these allocations. PerfView can also capture allocation stack traces to identify sources.
In BenchmarkDotNet, which attribute to use for measuring CPU performance and identifying code hotspots?
How to interpret a BenchmarkDotNet result showing Mean: 125.3 ns, StdDev: 45.2 ns?
+19 питань зі співбесід
Інші теми співбесід .NET
C# Basics
LINQ & Delegates
C# Language Essentials
ASP.NET Core Fundamentals
ASP.NET Core Request Lifecycle
Configuration & Settings
Application Lifecycle
Dependency Injection
Entity Framework Core
Minimal APIs
Web API Development
Async in ASP.NET Core
Authentication & Authorization
HttpClient & Networking
JSON Serialization
Entity Framework Core Advanced
C# Advanced Features
Clean Architecture
Logging, Monitoring & Observability
Unit Testing & xUnit
Integration Testing
Docker & Containerization
NuGet Package Management
Memory Management & GC
Reactive Programming
Async/await & Patterns
.NET Design Patterns
Security & Best Practices
SignalR & Real-time
Microservices Architecture
Опануй .NET для наступної співбесіди
Отримай доступ до всіх питань, flashcards, технічних тестів, вправ code review та симуляторів співбесід.
Почни безкоштовно