General Performance Tip: Choosing Between Conditional Statements – If, Switch, and Switch Expression Performance in C#

This article compares the performance of conditional if statements, switch statements, and switch expressions in C# code, with a focus on data retrieval.

Optimizing Code Performance: Leveraging Essential Tools and Best Practices

To optimize .NET code effectively, developers must utilize appropriate tools like profilers and analyzers. These resources reveal hidden performance issues and inefficiencies that can affect software quality. By measuring and analyzing their code, developers can focus on impactful optimizations, ensuring their applications operate at peak performance rather than relying solely on coding skills.

Microsoft .NET Code Analysis for Performance

Utilizing .NET code analysis tools is essential for identifying performance issues in code before execution. Modern .NET analyzers provide real-time warnings for inefficiencies, enabling developers to refine their code. This resource outlines practical examples and benchmarks, emphasizing that most performance problems stem from minor inefficiencies. Analyze, measure, and optimize for better performance.

Optimizing Data Manipulation with LINQ

LINQ is a powerful but potentially performance-hindering feature in .NET, offering a clean syntax for data querying. This content explores its inner workings, highlighting scenarios where it excels and where alternatives are more efficient. The aim is to maximize performance while leveraging LINQ, ensuring effective and rapid .NET code development.

Collection Performance

These articles delves into performance optimization for collections in .NET, covering topics like looping, sorting, and utilizing different types of objects. The author identified performance variations related to the object type in the collection and recommends conducting benchmark tests. All recommendations are specific to .NET 8.

Mastering Globalization

Globalization is essential for application development and should be integrated from the start, not as an afterthought. It encompasses more than just text translation, including nuances of languages, cultures, and data formats. Proper implementation enhances performance and user experience worldwide, while neglecting it can lead to significant difficulties and costs later.

Optimizing String Performance

Strings in .NET can severely impact performance if not managed properly. This guide explores string performance optimization, covering issues like concatenation, formatting, and memory allocation. It provides practical solutions using tools like StringBuilder and spans, offering benchmark-driven strategies to enhance application efficiency for developers dealing with strings.

Collection Performance: Is LINQ Always the Most Performant Choice?

The article explores the performance implications of using LINQ for collection queries, finding that a conventional foreach() loop outperforms LINQ by 1.75 times in identifying items matching a given query. The conclusion suggests benchmarking to determine the optimal approach based on the nature of the query and elements being sought.

General Performance Tip: Cloning Various Types

The post discusses the process of cloning different types of objects, with Microsoft recommending the use of JSON serialization for this purpose. The author explores the performance differences in cloning reference types, value types, and record types. Benchmark results using JsonSerializer reveal that cloning reference types is 1.015 times faster than cloning record types and 1.24 times more performant than cloning value types. The findings are shared for reference.

String Performance: Optimizing String Substring Extraction – Slicing vs. AsSpan()

The content presents an alternative approach to obtaining a substring using slicing with ReadOnlySpan and AsSpan() methods.