If you’re into this sort of stuff like me it can be fun to run benchmarks against bits of code to see the performance differences between different versions of .NET Framework / .NET Core. It can also be useful to justify effort to upgrade from one version of .NET to another. Either way it’s pretty simple to benchmark against multiple .NET versions using BenchmarkDotNet…
The first step is to install the SDKs for any versions of .NET which you wish to benchmark against.
Then you need to amend your project file to change the TargetFramework tag to TargetFrameworks (with a s) and add any frameworks you wish to benchmark against…
Next add the SimpleJob attribute for each relevant framework to the class which contains your benchmark methods…
Click on the image for a larger view in a new tab…
Then assuming your project.cs file has a call to BenchmarkRunner.Run similar to below…
BenchmarkRunner.Run<BenchmarkDotNet.Samples.MulitpleFrameworks>();
you can go ahead and run your console app without debugging and in release mode. You should see output like below…
Click on the image for a larger view in a new tab…