diff --git a/benchmark/Microsoft.IdentityModel.Benchmarks/AntiVirusFriendlyConfig.cs b/benchmark/Microsoft.IdentityModel.Benchmarks/AntiVirusFriendlyConfig.cs deleted file mode 100644 index a01b4039a6..0000000000 --- a/benchmark/Microsoft.IdentityModel.Benchmarks/AntiVirusFriendlyConfig.cs +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using BenchmarkDotNet.Columns; -using BenchmarkDotNet.Configs; -using BenchmarkDotNet.Jobs; -using BenchmarkDotNet.Toolchains.InProcess.Emit; -using BenchmarkDotNet.Reports; -using BenchmarkDotNet.Running; - - -namespace Microsoft.IdentityModel.Benchmarks -{ - // Define custom columns for P50 and P99 latency - public class P50Column : IColumn - { - public string Id => nameof(P50Column); - public string ColumnName => "P50"; - public bool IsDefault(Summary summary, BenchmarkCase benchmarkCase) => false; - public string GetValue(Summary summary, BenchmarkCase benchmarkCase) => GetValue(summary, benchmarkCase, SummaryStyle.Default); - public string GetValue(Summary summary, BenchmarkCase benchmarkCase, SummaryStyle style) - { - // Get the statistics for the current benchmark - var statistics = summary[benchmarkCase].ResultStatistics; - // Calculate the P50 latency using the Percentile method - var p50 = statistics.Percentiles.P50 / style.TimeUnit.NanosecondAmount; - // Format the value using the style - return p50.ToString($"F2") + $" {style.TimeUnit.Name}"; - } - public bool IsAvailable(Summary summary) => true; - public bool AlwaysShow => true; - public ColumnCategory Category => ColumnCategory.Statistics; - public int PriorityInCategory => 0; - public bool IsNumeric => true; - public UnitType UnitType => UnitType.Time; - public string Legend => "50th percentile of latency"; - } - - public class P95Column : IColumn - { - public string Id => nameof(P99Column); - public string ColumnName => "P95"; - public bool IsDefault(Summary summary, BenchmarkCase benchmarkCase) => false; - public string GetValue(Summary summary, BenchmarkCase benchmarkCase) => GetValue(summary, benchmarkCase, SummaryStyle.Default); - public string GetValue(Summary summary, BenchmarkCase benchmarkCase, SummaryStyle style) - { - // Get the statistics for the current benchmark - var statistics = summary[benchmarkCase].ResultStatistics; - // Calculate the P99 latency using the Percentile method - var p95 = statistics.Percentiles.P95 / style.TimeUnit.NanosecondAmount; - // Format the value using the style - return p95.ToString($"F2") + $" {style.TimeUnit.Name}"; - } - public bool IsAvailable(Summary summary) => true; - public bool AlwaysShow => true; - public ColumnCategory Category => ColumnCategory.Statistics; - public int PriorityInCategory => 0; - public bool IsNumeric => true; - public UnitType UnitType => UnitType.Time; - public string Legend => "95th percentile of latency"; - } - - public class P99Column : IColumn - { - public string Id => nameof(P99Column); - public string ColumnName => "P99"; - public bool IsDefault(Summary summary, BenchmarkCase benchmarkCase) => false; - public string GetValue(Summary summary, BenchmarkCase benchmarkCase) => GetValue(summary, benchmarkCase, SummaryStyle.Default); - public string GetValue(Summary summary, BenchmarkCase benchmarkCase, SummaryStyle style) - { - // Get the statistics for the current benchmark - var statistics = summary[benchmarkCase].ResultStatistics; - // Calculate the P99 latency using the Percentile method - var p99 = statistics.Percentiles.P90 / style.TimeUnit.NanosecondAmount; - // Format the value using the style - return p99.ToString($"F2") + $" {style.TimeUnit.Name}"; - } - public bool IsAvailable(Summary summary) => true; - public bool AlwaysShow => true; - public ColumnCategory Category => ColumnCategory.Statistics; - public int PriorityInCategory => 0; - public bool IsNumeric => true; - public UnitType UnitType => UnitType.Time; - public string Legend => "99th percentile of latency"; - } - - public class P100Column : IColumn - { - public string Id => nameof(P100Column); - public string ColumnName => "P100"; - public bool IsDefault(Summary summary, BenchmarkCase benchmarkCase) => false; - public string GetValue(Summary summary, BenchmarkCase benchmarkCase) => GetValue(summary, benchmarkCase, SummaryStyle.Default); - public string GetValue(Summary summary, BenchmarkCase benchmarkCase, SummaryStyle style) - { - // Get the statistics for the current benchmark - var statistics = summary[benchmarkCase].ResultStatistics; - // Calculate the P99 latency using the Percentile method - var p100 = statistics.Percentiles.P100 / style.TimeUnit.NanosecondAmount; - // Format the value using the style - return p100.ToString($"F2")+ $" {style.TimeUnit.Name}"; - } - public bool IsAvailable(Summary summary) => true; - public bool AlwaysShow => true; - public ColumnCategory Category => ColumnCategory.Statistics; - public int PriorityInCategory => 0; - public bool IsNumeric => true; - public UnitType UnitType => UnitType.Time; - public string Legend => "100th percentile of latency"; - } - - - public class AntiVirusFriendlyConfig : ManualConfig - { - public AntiVirusFriendlyConfig() - { - AddJob(Job.MediumRun - .WithToolchain(InProcessEmitToolchain.Instance)); - AddColumn(new P50Column(), new P95Column(), new P99Column(), new P100Column()); - } - } -} diff --git a/benchmark/Microsoft.IdentityModel.Benchmarks/BenchmarkConfig.cs b/benchmark/Microsoft.IdentityModel.Benchmarks/BenchmarkConfig.cs new file mode 100644 index 0000000000..f89730e3b7 --- /dev/null +++ b/benchmark/Microsoft.IdentityModel.Benchmarks/BenchmarkConfig.cs @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using BenchmarkDotNet.Columns; +using BenchmarkDotNet.Configs; +using BenchmarkDotNet.Jobs; +using BenchmarkDotNet.Toolchains.InProcess.Emit; + +namespace Microsoft.IdentityModel.Benchmarks +{ + public class BenchmarkConfig : ManualConfig + { + public BenchmarkConfig() + { + AddJob(Job.MediumRun + .WithToolchain(InProcessEmitToolchain.Instance)) + .AddColumn(StatisticColumn.P90, StatisticColumn.P95, StatisticColumn.P100); + } + } +} diff --git a/benchmark/Microsoft.IdentityModel.Benchmarks/CreateJWETests.cs b/benchmark/Microsoft.IdentityModel.Benchmarks/CreateJWETests.cs index e88595358f..61edeccd3e 100644 --- a/benchmark/Microsoft.IdentityModel.Benchmarks/CreateJWETests.cs +++ b/benchmark/Microsoft.IdentityModel.Benchmarks/CreateJWETests.cs @@ -8,7 +8,9 @@ namespace Microsoft.IdentityModel.Benchmarks { - [Config(typeof(AntiVirusFriendlyConfig))] + // dotnet run -c release -f net8.0 --filter Microsoft.IdentityModel.Benchmarks.CreateJWETests* + + [Config(typeof(BenchmarkConfig))] [HideColumns("Type", "Job", "WarmupCount", "LaunchCount")] [MemoryDiagnoser] public class CreateJWETests diff --git a/benchmark/Microsoft.IdentityModel.Benchmarks/CreateSignedHttpRequestTests.cs b/benchmark/Microsoft.IdentityModel.Benchmarks/CreateSignedHttpRequestTests.cs index a035cfa42c..8e85583e97 100644 --- a/benchmark/Microsoft.IdentityModel.Benchmarks/CreateSignedHttpRequestTests.cs +++ b/benchmark/Microsoft.IdentityModel.Benchmarks/CreateSignedHttpRequestTests.cs @@ -1,15 +1,14 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using System.Collections.Generic; using BenchmarkDotNet.Attributes; -using Microsoft.IdentityModel.JsonWebTokens; -using Microsoft.IdentityModel.Protocols; using Microsoft.IdentityModel.Protocols.SignedHttpRequest; -using Microsoft.IdentityModel.Tokens; 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 diff --git a/benchmark/Microsoft.IdentityModel.Benchmarks/CreateTokenTests.cs b/benchmark/Microsoft.IdentityModel.Benchmarks/CreateTokenTests.cs index 85acf48301..18394bb8be 100644 --- a/benchmark/Microsoft.IdentityModel.Benchmarks/CreateTokenTests.cs +++ b/benchmark/Microsoft.IdentityModel.Benchmarks/CreateTokenTests.cs @@ -8,6 +8,10 @@ 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 { diff --git a/benchmark/Microsoft.IdentityModel.Benchmarks/ValidateJWEAsyncTests.cs b/benchmark/Microsoft.IdentityModel.Benchmarks/ValidateJWEAsyncTests.cs index 12042c3153..664ec00b12 100644 --- a/benchmark/Microsoft.IdentityModel.Benchmarks/ValidateJWEAsyncTests.cs +++ b/benchmark/Microsoft.IdentityModel.Benchmarks/ValidateJWEAsyncTests.cs @@ -10,7 +10,9 @@ namespace Microsoft.IdentityModel.Benchmarks { - [Config(typeof(AntiVirusFriendlyConfig))] + // dotnet run -c release -f net8.0 --filter Microsoft.IdentityModel.Benchmarks.ValidateJWEAsyncTests* + + [Config(typeof(BenchmarkConfig))] [HideColumns("Type", "Job", "WarmupCount", "LaunchCount")] [MemoryDiagnoser] public class ValidateJWEAsyncTests diff --git a/benchmark/Microsoft.IdentityModel.Benchmarks/ValidateSignedHttpRequestAsyncTests.cs b/benchmark/Microsoft.IdentityModel.Benchmarks/ValidateSignedHttpRequestAsyncTests.cs index 814aaf5266..6c359f91bf 100644 --- a/benchmark/Microsoft.IdentityModel.Benchmarks/ValidateSignedHttpRequestAsyncTests.cs +++ b/benchmark/Microsoft.IdentityModel.Benchmarks/ValidateSignedHttpRequestAsyncTests.cs @@ -1,17 +1,17 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using BenchmarkDotNet.Attributes; -using Microsoft.IdentityModel.JsonWebTokens; -using Microsoft.IdentityModel.Protocols; using Microsoft.IdentityModel.Protocols.SignedHttpRequest; using Microsoft.IdentityModel.Tokens; 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 diff --git a/benchmark/Microsoft.IdentityModel.Benchmarks/ValidateTokenAsyncTests.cs b/benchmark/Microsoft.IdentityModel.Benchmarks/ValidateTokenAsyncTests.cs index 31ecedce60..6db2636c38 100644 --- a/benchmark/Microsoft.IdentityModel.Benchmarks/ValidateTokenAsyncTests.cs +++ b/benchmark/Microsoft.IdentityModel.Benchmarks/ValidateTokenAsyncTests.cs @@ -9,7 +9,9 @@ namespace Microsoft.IdentityModel.Benchmarks { - [Config(typeof(AntiVirusFriendlyConfig))] + // dotnet run -c release -f net8.0 --filter Microsoft.IdentityModel.Benchmarks.ValidateTokenAsyncTests* + + [Config(typeof(BenchmarkConfig))] [HideColumns("Type", "Job", "WarmupCount", "LaunchCount")] [MemoryDiagnoser] public class ValidateTokenAsyncTests