Skip to main content

Posts

Showing posts from September, 2018

Benchmarking in C# - Simple Job attribute

In this post I am going to continue my servies on BenchMarkDotNet and I will explain what the various parameters do that are present in the simplejob attribute.  Now I say all....... the documentation is not great so I will explain what 3 out of the 4 do :) So If you remember in my previous post I had a MyFirstBenchmark class which contained the details about the benchmark test that I wanted to run. In this class there is an attribute called SimpleJob and this attribute contains a few parameters that can be configured when you run a test.  By default BenchMarkDotNet will choose the number of iterations that will return the best precision. However, using the simplejob attribute allows you to quickly get a set of statistics. Below is how my test was setup: Now as you can see I had the following parameters in the SimpleJob attribute: launchCount - This parameter allows you to define how many times the benchmarking test is run warmupCount - This parameter a

Benchmarking in C#

A bit of a change to my normal blog posts this time.... In the next few posts I will be talking about benchmark testing and in particular a NuGet package that allows you to run bench-marking tests in a .NET environment.  So in this post I will demonstrate how you can use a NuGet package to measure the time it takes to open notepad on your local machine.  This will be the starting point and I am aiming to build up some more complex examples as I learn about the NuGet package.  So here goes....... The NuGet package is called BenchMarkDotNet and is a powerful library for bench-marking various tasks.  The GitHub page can be found here: https://github.com/dotnet/BenchmarkDotNet So to use this package, the first thing you need to do is create a new Console App (.NET Framework) project in Visual Studio  You then need to add the NuGet package to the project (You should find the NuGet package if you search for 'BenchMarkDotNet'): At the time of