How to benchmark C# code using BenchmarkDotNet

Maria J. Danford

BenchmarkDotNet is a light-weight, open source, powerful .Net library that can transform your approaches into benchmarks, track those approaches, and then deliver insights into the general performance details captured. It is quick to create BenchmarkDotNet benchmarks and the final results of the benchmarking system are user friendly as well.

You can get advantage of BenchmarkDotNet to benchmark the two .Net Framework and .Net Core applications. In this short article we’ll take a look at how we can do the job with BenchmarkDotNet in .Net Core. You can find BenchmarkDotNet on GitHub.

To do the job with the code illustrations provided in this short article, you ought to have Visual Studio 2019 put in in your program. If you do not presently have a duplicate, you can obtain Visual Studio 2019 right here. 

Build a console software venture in Visual Studio

First off, let’s generate a .Net Core console software venture in Visual Studio. Assuming Visual Studio 2019 is put in in your program, adhere to the ways outlined down below to generate a new .Net Core console software venture in Visual Studio.

  1. Launch the Visual Studio IDE.
  2. Click on “Create new venture.”
  3. In the “Create new project” window, select “Console Application (.Net Core)” from the checklist of templates exhibited.
  4. Click Following.
  5. In the “Configure your new project” window shown following, specify the title and place for the new venture.
  6. Click Build.

This will generate a new .Net Core console software venture in Visual Studio 2019.

Notice that when you generate the console software venture, the ensuing System class (created routinely in the System.cs file) will glimpse like this:

Copyright © 2020 IDG Communications, Inc.

Next Post

Amazon, Google, and Microsoft take their clouds to the edge

It may well surprise you to study that the large 3 general public clouds – AWS, Google Could System, and Microsoft Azure – are all commencing to deliver edge computing capabilities. It’s puzzling, for the reason that the phrase “edge computing” implies a mini datacenter, usually linked to IoT gadgets […]

Subscribe US Now