|
1 | 1 | # Getting started
|
2 |
| - |
3 | 2 | To get started with BenchmarkDotNet, please follow these steps.
|
4 | 3 |
|
5 | 4 | ## Step 1. Create a project
|
6 | 5 | Create a new console application.
|
7 | 6 |
|
8 | 7 | ## Step 2. Installation
|
9 |
| - |
10 | 8 | Install BenchmarkDotNet via the NuGet package: [BenchmarkDotNet](https://www.nuget.org/packages/BenchmarkDotNet/)
|
11 | 9 |
|
12 |
| -``` |
13 |
| -PM> Install-Package BenchmarkDotNet |
| 10 | +```cmd |
| 11 | +> dotnet add package BenchmarkDotNet |
14 | 12 | ```
|
15 | 13 |
|
16 | 14 | Read more about BenchmarkDotNet NuGet packages: @docs.nuget
|
@@ -58,39 +56,50 @@ namespace MyBenchmarks
|
58 | 56 | }
|
59 | 57 | ```
|
60 | 58 |
|
61 |
| -The `BenchmarkRunner.Run<Md5VsSha256>()` call runs your benchmarks and print results to console output. |
| 59 | +The `BenchmarkRunner.Run<Md5VsSha256>()` call runs your benchmarks and prints results to the console. |
62 | 60 |
|
63 |
| -## Step 4. View results |
| 61 | +## Step 4. Run benchmarks |
| 62 | +Start your console application to run the benchmarks. The application must be built in the Release configuration. |
| 63 | + |
| 64 | +```cmd |
| 65 | +> dotnet run -c Release |
| 66 | +``` |
| 67 | + |
| 68 | +## Step 5. View results |
64 | 69 | View the results. Here is an example of output from the above benchmark:
|
65 | 70 |
|
66 | 71 | ```
|
67 |
| -BenchmarkDotNet=v0.11.3, OS=Windows 10.0.17134.472 (1803/April2018Update/Redstone4) |
68 |
| -Intel Core i7-2630QM CPU 2.00GHz (Sandy Bridge), 1 CPU, 8 logical and 4 physical cores |
69 |
| -Frequency=1948699 Hz, Resolution=513.1629 ns, Timer=TSC |
70 |
| -.NET Core SDK=2.1.502 |
71 |
| - [Host] : .NET Core 2.1.6 (CoreCLR 4.6.27019.06, CoreFX 4.6.27019.05), 64bit RyuJIT |
72 |
| - DefaultJob : .NET Core 2.1.6 (CoreCLR 4.6.27019.06, CoreFX 4.6.27019.05), 64bit RyuJIT |
73 |
| -
|
74 |
| -
|
75 |
| -| Method | Mean | Error | StdDev | |
76 |
| -|------- |----------:|----------:|----------:| |
77 |
| -| Sha256 | 100.90 us | 0.5070 us | 0.4494 us | |
78 |
| -| Md5 | 37.66 us | 0.1290 us | 0.1207 us | |
| 72 | +BenchmarkDotNet=v0.13.2, OS=Windows 10 (10.0.19045.2251) |
| 73 | +Intel Core i7-4770HQ CPU 2.20GHz (Haswell), 1 CPU, 8 logical and 4 physical cores |
| 74 | +.NET SDK=7.0.100 |
| 75 | + [Host] : .NET 7.0.0 (7.0.22.51805), X64 RyuJIT AVX2 |
| 76 | + DefaultJob : .NET 7.0.0 (7.0.22.51805), X64 RyuJIT AVX2 |
| 77 | +
|
| 78 | +
|
| 79 | +| Method | Mean | Error | StdDev | |
| 80 | +|------- |---------:|---------:|---------:| |
| 81 | +| Sha256 | 51.57 us | 0.311 us | 0.291 us | |
| 82 | +| Md5 | 21.91 us | 0.138 us | 0.129 us | |
79 | 83 | ```
|
80 | 84 |
|
| 85 | +## Step 6. Analyze results |
| 86 | +BenchmarkDotNet will automatically create basic reports in the `.\BenchmarkDotNet.Artifacts\results` folder that can be shared and analyzed. |
81 | 87 |
|
82 |
| -## Step 5. Analyze results |
| 88 | +To help analyze performance in further depth, you can configure your benchmark to collect and output more detailed information. Benchmark configuration can be conveniently changed by adding attributes to the class containing your benchmarks. For example: |
83 | 89 |
|
84 |
| -Analyze it. In your bin directory, you can find a lot of useful files with detailed information. For example: |
| 90 | +* [Diagnosers](../configs/diagnosers.md) |
| 91 | + * GC allocations: `[MemoryDiagnoser]` |
| 92 | + * Code size and disassembly: `[DisassemblyDiagnoser]` |
| 93 | + * Threading statistics: `[ThreadingDiagnoser]` |
| 94 | +* [Exporters](../configs/exporters.md) |
| 95 | + * CSV reports with raw data: `[CsvMeasurementsExporter]` |
| 96 | + * JSON reports with raw data: `[JsonExporter]` |
| 97 | + * Plots (if you have installed R): `[RPlotExporter]` |
85 | 98 |
|
86 |
| -* Csv reports with raw data: `Md5VsSha256-report.csv`, `Md5VsSha256-runs.csv` |
87 |
| -* Markdown reports: `Md5VsSha256-report-default.md`, `Md5VsSha256-report-stackoverflow.md`, `Md5VsSha256-report-github.md` |
88 |
| - * Plain report and log: `Md5VsSha256-report.txt`, `Md5VsSha256.log` |
89 |
| - * Plots (if you have installed R): `Md5VsSha256-barplot.png`, `Md5VsSha256-boxplot.png`, and so on. |
| 99 | +For more information, see [Configs](../configs/configs.md). |
90 | 100 |
|
91 | 101 | ## Next steps
|
92 |
| - |
93 |
| -BenchmarkDotNet provides a lot of features which help to high-quality performance research. |
94 |
| -If you want to know more about BenchmarkDotNet features, checkout the [Overview](../overview.md) page. |
95 |
| -If you want have any questions, checkout the [FAQ](../faq.md) page. |
96 |
| -If you didn't find answer for your question on this page, [ask it on gitter](https://gitter.im/dotnet/BenchmarkDotNet) or [create an issue](https://github.com/dotnet/BenchmarkDotNet/issues). |
| 102 | +BenchmarkDotNet provides features which aid high-quality performance research. |
| 103 | +If you want to know more about BenchmarkDotNet features, check out the [Overview](../overview.md) page. |
| 104 | +If you have any questions, check out the [FAQ](../faq.md) page. |
| 105 | +If you didn't find an answer for your question on this page, [ask it on Gitter](https://gitter.im/dotnet/BenchmarkDotNet) or [create an issue on GitHub](https://github.com/dotnet/BenchmarkDotNet/issues). |
0 commit comments