How to benchmark C# code using BenchmarkDotNet

BenchmarkDotNet is a lightweight, open resource, effective .Net library that can completely transform your solutions into benchmarks, monitor all those solutions, and then present insights into the general performance information captured. It is quick to write BenchmarkDotNet benchmarks and the effects of the benchmarking approach are consumer welcoming as perfectly.

You can take edge of BenchmarkDotNet to benchmark equally .Net Framework and .Net Core programs. In this write-up we’ll investigate how we can do the job with BenchmarkDotNet in .Net Core. You can find BenchmarkDotNet on GitHub.

To do the job with the code examples provided in this write-up, you really should have Visible Studio 2019 set up in your procedure. If you really do not now have a duplicate, you can down load Visible Studio 2019 listed here. 

Generate a console software venture in Visible Studio

Very first off, let us build a .Net Core console software venture in Visible Studio. Assuming Visible Studio 2019 is set up in your procedure, comply with the techniques outlined under to build a new .Net Core console software venture in Visible Studio.

  1. Start the Visible Studio IDE.
  2. Click on on “Create new venture.”
  3. In the “Create new project” window, decide on “Console Application (.Net Core)” from the record of templates exhibited.
  4. Click on Following.
  5. In the “Configure your new project” window proven subsequent, specify the identify and area for the new venture.
  6. Click on Generate.

This will build a new .Net Core console software venture in Visible Studio 2019.

Take note that when you build the console software venture, the ensuing Program course (created automatically in the Program.cs file) will appear like this:

Copyright © 2020 IDG Communications, Inc.