Benchmarking minimal APIs with BenchmarkDotNet
BenchmarkDotNet is a framework that allows you to measure written code and compare performance between libraries written in different versions or compiled with different .NET frameworks.
This tool is used for calculating the time taken for the execution of a task, the memory used, and many other parameters.
Our case is a very simple scenario. We want to compare the response times of two applications written to the same version of the .NET Framework.
How do we perform this comparison? We take an HttpClient
object and start calling the methods that we have also defined for the load testing case.
We will therefore obtain a comparison between two methods that exploit the same HttpClient
object and recall methods with the same functionality, but one is written with the ASP.NET Web API and the traditional controllers, while the other is written using minimal APIs.
BenchmarkDotNet helps you to transform methods into benchmarks...