I’m a big fan of LinqPad. Anytime I need to test a small code snippet, it is my 'goto' tool.
Today I was looking at the latest beta release where I noticed the following announcement:
LINQPad now lets you benchmark code with a single keypress! Simply select the code you want to benchmark, and press Ctrl+Shift+B. LINQPad uses the industrial-grade BenchmarkDotNet library as the underlying engine, while providing a customizable real-time graphical display of results. For a complete tutorial, press Ctrl+F1 and type benchmark.
Whow! That looks great! Let’s give this feature a try:
- Download and extra the LinqPad 7 Beta release.
- Run LinqPad.
- At the top change the Language to ‘C# Program’.
- Now paste the following code:
- Select the 2 methods at the bottom and hit
Ctrl+Shift+B
.
- LinqPad will ask you to download BenchmarkDotNet. Click Yes to continue.
- After downloading the NuGet package and it’s dependencies, click ‘I Accept’ to accept the License conditions.
- Now LinqPad will start a benchmark run and visualize the results.