Leveraging performance improvements
How nice it is to get better performance without changing our code! Yes, that's what the .NET Core team has been doing for us. There are a number of performance improvements in the .NET 5 runtime that will make your code run faster without changing a single line (except for targeting the framework at .NET 5).
Most performance improvements are a continuation of the language and runtime features introduced in prior .NET Core versions. The .NET team is now incorporating these features in widely used methods and classes for developers to benefit from. I'll provide some notable examples of these enhancements later in the chapter.
One critical consideration for performance-oriented C# developers is to reduce the number of times that garbage collection has to kick in. In C# 7.2 and .NET Core 2.1, a new system type, Span<T>
, was added that helps developers to access contiguous memory without creating additional memory allocations....