-
-
Notifications
You must be signed in to change notification settings - Fork 968
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add JitStatsDiagnoserAttribute (#2250)
- Loading branch information
Showing
5 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- | ||
uid: BenchmarkDotNet.Samples.IntroJitStatsDiagnoser | ||
--- | ||
|
||
## Sample: IntroJitStatsDiagnoser | ||
|
||
This diagnoser shows various stats from the JIT compiler that were collected during entire benchmark run (warmup phase and BenchmarkDotNet-generated boilerplate code are included): | ||
* Amount of JITted methods. | ||
* Amount of [tiered methods](https://learn.microsoft.com/en-us/dotnet/core/whats-new/dotnet-core-3-0#tiered-compilation). | ||
* How much memory JIT allocated during the benchmark. | ||
|
||
### Restrictions | ||
|
||
* Windows only | ||
|
||
### Source code | ||
|
||
[!code-csharp[IntroJitStatsDiagnoser.cs](../../../samples/BenchmarkDotNet.Samples/IntroJitStatsDiagnoser.cs)] | ||
|
||
### Output | ||
|
||
| Method | Mean | Error | StdDev | Methods JITted | Methods Tiered | JIT allocated memory | | ||
|------- |---------:|---------:|---------:|---------------:|---------------:|---------------------:| | ||
| Sleep | 15.50 ms | 0.052 ms | 0.048 ms | 1,102 | 214 | 221,736 B | | ||
|
||
### Links | ||
|
||
* @docs.diagnosers | ||
* The permanent link to this sample: @BenchmarkDotNet.Samples.IntroJitStatsDiagnoser | ||
|
||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System.Threading; | ||
using BenchmarkDotNet.Attributes; | ||
|
||
namespace BenchmarkDotNet.Samples | ||
{ | ||
[Diagnostics.Windows.Configs.JitStatsDiagnoser] | ||
public class IntroJitStatsDiagnoser | ||
{ | ||
[Benchmark] | ||
public void Sleep() => Thread.Sleep(10); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/BenchmarkDotNet.Diagnostics.Windows/Configs/JitStatsDiagnoserAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System; | ||
using BenchmarkDotNet.Configs; | ||
using JetBrains.Annotations; | ||
|
||
namespace BenchmarkDotNet.Diagnostics.Windows.Configs | ||
{ | ||
[PublicAPI] | ||
[AttributeUsage(AttributeTargets.Class)] | ||
public class JitStatsDiagnoserAttribute : Attribute, IConfigSource | ||
{ | ||
public JitStatsDiagnoserAttribute() | ||
{ | ||
Config = ManualConfig.CreateEmpty().AddDiagnoser(new JitStatsDiagnoser()); | ||
} | ||
|
||
public IConfig Config { get; } | ||
} | ||
} |