In this workshop, you will discover how to measure the performance of .NET applications and perform targeted optimisations to make the code execute more quickly and with fewer allocations.
You will learn to use tools such as Benchmark .NET to measure the performance of an existing application. These measurements will act as a baseline before begining to make high-performance optimisations. You will explore the latest C# and .NET Core features and APIs such as Span<T>, ArrayPool and the latest System.IO.Pipelines.
By the end of this workshop, you will have a practical understanding of how to approach measuring code execution and memory usage. You will have applied modern techniques to refactor and optimise the code which you can use in your day-to-day work as a .NET developer.
This workshop includes instruction from slides, practical code demos and some activities to apply the features being demonstrated.
Main Agenda
Note: This is not an exhaustive list of all the content we’ll cover.
- What is performance?
- Measuring application and code performance
- Span<T>, ReadOnlySpan<T> and Memory<T>
- ArrayPool
- System.IO.Pipelines and ReadOnlySequence<T>
- .NET Core 3.0 JSON APIs
Who Should Attend?
This workshop covers some quite advanced topics so a level of C# and .NET experience is required. The high-performance topics themselves will be covered from a beginner level so there is no need for prior knowledge of benchmarking, Span<T> etc.
Workshop Resources
Code and Activities Repository – Will be available before the workshop. A clone is required to take part in the activities.
The below repos are demos I’ll show. You can optionally clone these but it is not a requirement.
- MemoryPoolSample Repository
- SequenceReaderSample Repository
- ChannelSample Repository
- System.Text.Json Demo Repository
- DotMemory Demo Repository
- String.Create Demo Repository
Prerequisites
To complete the activities in this workshop you will need to install the following:
-
.NET Core 3.0 Preview 9 (or higher) Download.
-
An editor or IDE of your choice to work with the .NET Core 3.0 solutions – VS Code, Visual Studio 2019 16.3 Preview 3 (or higher) etc. Download.
- Clone the Code and Activities Repository onto your local machine.
Other Resources
- https://www.stevejgordon.co.uk/an-introduction-to-sequencereader
- https://www.stevejgordon.co.uk/an-introduction-to-system-threading-channels
- https://benchmarkdotnet.org
- https://msdn.microsoft.com/en-us/magazine/mt814808.aspx
- https://adamsitnik.com/Span/
- https://adamsitnik.com/Array-Pool/
- https://devblogs.microsoft.com/dotnet/system-io-pipelines-high-performance-io-in-net/
- https://blog.marcgravell.com/2018/07/pipe-dreams-part-1.html