Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update benchmark config #2468

Merged
merged 3 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ namespace Microsoft.IdentityModel.Benchmarks
{
// dotnet run -c release -f net8.0 --filter Microsoft.IdentityModel.Benchmarks.AsymmetricAdapterSignatures.*

[Config(typeof(BenchmarkConfig))]
[HideColumns("Type", "Job", "WarmupCount", "LaunchCount")]
[MemoryDiagnoser]
public class AsymmetricAdapterSignatures
{
private byte[] _bytesToSign;
Expand Down Expand Up @@ -46,7 +43,7 @@ public void Setup()
}

/// <summary>
/// In this case, dotnet creates a buffer to hold the signature.
/// In this case, .NET creates a buffer to hold the signature.
/// ArrayPool is not used, because the buffer is created by the framework and not the user.
/// The buffer is not returned to the pool, and must be garbage collected.
/// </summary>
Expand All @@ -57,7 +54,7 @@ public void SignDotnetCreatingBufferRSA()
}

/// <summary>
/// In this case, the user obatins a buffer to hold the signature frm the array pool.
/// In this case, the user obtains a buffer to hold the signature from the array pool.
/// A new api available in .NET 5.0+ is used to provide the buffer to place the signature.
/// The size of the bytes written is returned in the out parameter, size.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@

using BenchmarkDotNet.Columns;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Diagnosers;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Toolchains.InProcess.Emit;
using BenchmarkDotNet.Order;
using Perfolizer.Horology;

namespace Microsoft.IdentityModel.Benchmarks
Expand All @@ -14,12 +15,15 @@ public class BenchmarkConfig : ManualConfig
public BenchmarkConfig()
{
AddJob(Job.MediumRun
.WithToolchain(InProcessEmitToolchain.Instance)
.WithLaunchCount(4)
.WithMaxAbsoluteError(TimeInterval.FromMilliseconds(10)))
// uncomment to disable validation to enable debuging through benchmarks
// uncomment to disable validation to enable debugging through benchmarks
//.WithOption(ConfigOptions.DisableOptimizationsValidator, true)
.AddColumn(StatisticColumn.P90, StatisticColumn.P95, StatisticColumn.P100);
.AddColumn(StatisticColumn.P90, StatisticColumn.P95, StatisticColumn.P100)
.WithOrderer(new DefaultOrderer(SummaryOrderPolicy.Method))
.HideColumns(Column.WarmupCount, Column.Type, Column.Job)
.AddDiagnoser(MemoryDiagnoser.Default); // https://benchmarkdotnet.org/articles/configs/diagnosers.html
//.AddDiagnoser(new EtwProfiler()) // Uncomment to generate traces / flame graphs. Doc: https://adamsitnik.com/ETW-Profiler/
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ namespace Microsoft.IdentityModel.Benchmarks
{
// dotnet run -c release -f net8.0 --filter Microsoft.IdentityModel.Benchmarks.CreateJWETests*

[Config(typeof(BenchmarkConfig))]
[HideColumns("Type", "Job", "WarmupCount", "LaunchCount")]
[MemoryDiagnoser]
public class CreateJWETests
{
private JsonWebTokenHandler _jsonWebTokenHandler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ namespace Microsoft.IdentityModel.Benchmarks
{
// dotnet run -c release -f net8.0 --filter Microsoft.IdentityModel.Benchmarks.CreateSignedHttpRequestTests*

[Config(typeof(BenchmarkConfig))]
[HideColumns("Type", "Job", "WarmupCount", "LaunchCount")]
[MemoryDiagnoser]
public class CreateSignedHttpRequestTests
{
private SignedHttpRequestHandler _signedHttpRequestHandler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ namespace Microsoft.IdentityModel.Benchmarks
{
// dotnet run -c release -f net8.0 --filter Microsoft.IdentityModel.Benchmarks.CreateTokenTests*

[Config(typeof(BenchmarkConfig))]
[HideColumns("Type", "Job", "WarmupCount", "LaunchCount")]
[MemoryDiagnoser]
public class CreateTokenTests
{
private JsonWebTokenHandler _jsonWebTokenHandler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@
<ErrorOnDuplicatePublishOutputFiles>False</ErrorOnDuplicatePublishOutputFiles>
</PropertyGroup>

<!-- Uncomment only when running EtwProfiler diagnoser on Release-->
<!-- https://learn.microsoft.com/en-us/visualstudio/msbuild/common-msbuild-project-properties -->
<!--<PropertyGroup>
<DebugType>pdbonly</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet.Diagnostics.Windows" Version="0.13.5" />
</ItemGroup>-->

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.5" />
</ItemGroup>
Expand Down
9 changes: 8 additions & 1 deletion benchmark/Microsoft.IdentityModel.Benchmarks/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Microsoft.IdentityModel.Protocols.SignedHttpRequest;
using Microsoft.IdentityModel.Tokens;
using BenchmarkDotNet.Running;
using BenchmarkDotNet.Configs;

namespace Microsoft.IdentityModel.Benchmarks
{
Expand All @@ -13,7 +14,13 @@ public static void Main(string[] args)
{
//DebugThroughTests();

BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args);
#if DEBUG
var benchmarkConfig = ManualConfig.Union(DefaultConfig.Instance, new DebugInProcessConfig()); // Allows debugging into benchmarks
#else
var benchmarkConfig = ManualConfig.Union(DefaultConfig.Instance, new BenchmarkConfig());
#endif

BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args, benchmarkConfig);
}
private static void DebugThroughTests()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ namespace Microsoft.IdentityModel.Benchmarks
{
// dotnet run -c release -f net8.0 --filter Microsoft.IdentityModel.Benchmarks.ValidateJWEAsyncTests*

[Config(typeof(BenchmarkConfig))]
[HideColumns("Type", "Job", "WarmupCount", "LaunchCount")]
[MemoryDiagnoser]
public class ValidateJWEAsyncTests
{
private JsonWebTokenHandler _jsonWebTokenHandler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ namespace Microsoft.IdentityModel.Benchmarks
{
// dotnet run -c release -f net8.0 --filter Microsoft.IdentityModel.Benchmarks.ValidateSignedHttpRequestAsyncTests*

[Config(typeof(BenchmarkConfig))]
[HideColumns("Type", "Job", "WarmupCount", "LaunchCount")]
[MemoryDiagnoser]
public class ValidateSignedHttpRequestAsyncTests
{
private SignedHttpRequestHandler _signedHttpRequestHandler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ namespace Microsoft.IdentityModel.Benchmarks
{
// dotnet run -c release -f net8.0 --filter Microsoft.IdentityModel.Benchmarks.ValidateTokenAsyncTests*

[Config(typeof(BenchmarkConfig))]
[HideColumns("Type", "Job", "WarmupCount", "LaunchCount")]
[MemoryDiagnoser]
public class ValidateTokenAsyncTests
{
private JsonWebTokenHandler _jsonWebTokenHandler;
Expand Down
Loading