Back to Browse

128. How to Benchmark your .NET code

141 views
Jan 28, 2026
15:23

In this Betatalks episode, Christian and Jelle show why performance matters and how to benchmark .NET code with BenchmarkDotNet. Using a simple example, they compare the performance between string concatenation vs. using a StringBuilder and reveal how small choices can lead to big performance and memory differences. They wrap up by explaining how BenchmarkDotNet helps compare .NET versions and catch performance regressions early. Links for more information - https://benchmarkdotnet.org/ Timestamps 00:00 - Introduction of benchmarking .NET code and why performance matters 01:40 - You can do with better performance 03:04 - Demo: Benchmark code (New console app and StringConcatenator class with two implementations (StringBuilder vs +) 04:20 - Benchmark .NET package 05:10 - Marking methods with Benchmark-attribute and using BenchmarkRunner to execute benchmarks 06:41 - Requirements for running Benchmark correctly 07:34 - Warmups, overhead, and how BenchmarkDotNet stabilizes measurements 08:15 - Attribute: ShortRunJob 08:52 - First results: StringBuilder vs String 09:42 - Changing iteration counts and introducing parameterized benchmarks 10:18 - Baseline Benchmark and ratio column to compare scenarios 11:00 - Adding MemoryDiagnoser 13:55 - Closing remarks and wrap-up There is more to come! https://www.betabit.nl/en

Download

0 formats

No download links available.

128. How to Benchmark your .NET code | NatokHD