This is a 3 hour workshop run at ProgNET 2019.
- Clone this repository locally
- Ensure you have the Prerequisites installed and working.
During this workshop, we will discuss and apply various modern C# and .NET techniques to optimise our codebases. We'll begin by learning how to measure the performance of existing code with benchmarks. We learn about Span and apply it to optimise some simple code. We'll look at high-performance, string construction with String.Create. We'll learn about the shared ArrayPool with a practical excercise to measure the allocation reduction it can produce. We'll learn about the new high-performance JSON APIs from Microsoft.
This workshop is focused on introducing as many high-performance features as possible, with practical demos and excercises that help the audience to cement their understanding of the APIs and types we cover in this session.
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.
If you've previously seen my talk 'Turbocharged: Writing High-Performance C# and .NET Code' then the themes and a reasonable amount of the content overlap. This dives deeper into some of the topics and includes more demos and some practical activites.
Activity instructions are included in the folder 'activities'. You will need to follow these for each activity during the workshop. In some cases, more detailed notes are included in the sub-folder 'detailed'. These provide more granular steps if you get stuck with a particular activity.
The repository also includes a folder called 'steps' which provides solutions and/or examples for the end state of each activity. If you get stuck or left behind you can load one of these and continue from that step. Some activities may start from a new starting solution.
Activity | Topics |
---|---|
Activity #1 | Create a basic benchmark |
Activity #2 | Optimise some code with Span |
Activity #3 | Add parameters to the benchmarks |
Activity #4 | Applying String.Create for rapid, low-allocation string construction |
Activity #5 | Switching to ArrayPool to reduce array allocations |
Activity #6 | Switch to the System.Text.Json high-level APIs |