-
Notifications
You must be signed in to change notification settings - Fork 4.9k
BenchmarkDotNet can benchmark local CoreFX builds using CoreRun #31921
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NICE 👍
|
||
We recommend using [BenchmarkDotNet](https://github.com/dotnet/BenchmarkDotNet) as it allows specifying custom SDK paths and measuring performance not just in-proc but also out-of-proc as a dedicated executable. | ||
|
||
``` | ||
<ItemGroup> | ||
<PackageReference Include="BenchmarkDotNet" Version="0.10.13" /> | ||
<PackageReference Include="BenchmarkDotNet" Version="0.11.1" /> | ||
</ItemGroup> | ||
``` | ||
|
||
## Defining your benchmark | ||
|
||
See [BenchmarkDotNet](http://benchmarkdotnet.org/Guides/GettingStarted.htm) documentation -- minimally you need to adorn a public method with the `[Benchmark]` attribute but there are many other ways to customize what is done such as using parameter sets or setup/cleanup methods. Of course, you'll want to bracket just the relevant code in your benchmark, ensure there are sufficient iterations that you minimise noise, as well as leaving the machine otherwise idle while you measure. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This link should be updated: https://benchmarkdotnet.org/articles/guides/getting-started.html
I added redirects for all "old-style" doc pages, so people will see this page anyway, but I still want to update links wherever possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
||
**Important:** BenchmarkDotNet will generate the right `.csproj` file for the self-contained app. It's going to reference the `.csproj` file of the project which defines benchmarks. It's going to work even if your project is not self-contained app targeting local CoreFX build. So you can just create a new solution with console app in Visual Studio, install BenchmarkDotNet and it's going to do the right thing for you. | ||
dotnet run -c Release -f netcoreapp2.1 -- -f *MyBenchmarkName* --coreRun "C:\Projects\corefx\bin\testhost\netcoreapp-Windows_NT-Release-x64\shared\Microsoft.NETCore.App\9.9.9\CoreRun.exe" | ||
|
||
**Hint:** If you are curious to know what BDN does internally you just need to apply `[KeepBenchmarkFiles]` attribute to your class or set `KeepBenchmarkFiles = true` in your config file. After runing the benchmarks you can find the auto-generated files in `%pathToBenchmarkApp\bin\Release\$TFM\` folder. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo....'runing'
Example: | ||
2. Create a new .NET Core console app using your favorite IDE | ||
3. Install BenchmarkDotNet (0.11.1+) | ||
4. Define the benchmarks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing #1?
using BenchmarkDotNet.Loggers; | ||
using BenchmarkDotNet.Toolchains.CsProj; | ||
using BenchmarkDotNet.Toolchains.DotNetCli; | ||
9. Run the benchmarks using `--coreRun` from the fist step. Save the results in a dedicated folder. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo
|
||
**Hint:** If you would like to compare the performance of different CoreFX versions, you just need to define multiple jobs, each using it's own toolchain. | ||
1. Before you start benchmarking the code you need to build entire CoreFX in Release which is going to generate the right CoreRun bits for you: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@danmosemsft the missing #1
is here
…et/corefx#31921) * 0.11.1 knows how to use CoreRun to run the local CoreFX benchmarks! * fix typos and old link Commit migrated from dotnet/corefx@3475a8d
BDN can now run benchmarks using CoreRun and all you need to do is to provide the path to CoreRun using console argument.
It simplifies everything and makes it very easy to benchmark local CoreFX builds!
Please take a look at the doc change to find out more.
/cc @jorive @stephentoub @danmosemsft @AndreyAkinshin