Skip to content

Commit

Permalink
Update performance-testing.md
Browse files Browse the repository at this point in the history
  • Loading branch information
pmaytak authored Sep 9, 2023
1 parent a537632 commit 1763efc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions msal-dotnet-articles/advanced/performance-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ title: Performance testing of MSAL.NET

[Microsoft.Identity.Test.Performance](https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/tree/main/tests/Microsoft.Identity.Test.Performance) project uses [BenchmarkDotNet](https://benchmarkdotnet.org/articles/overview.html) library for performance testing of MSAL functionality. [Program.cs](https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/blob/main/tests/Microsoft.Identity.Test.Performance/Program.cs) contains benchmark classes used to test different scenarios.

This performance test project is a console app. Behind the scenes when the project is run, BenchmarkDotNet builds and outputs this test project into a temporary working directory. Then it creates a separate process where all the benchmarking measurements are done.
This performance test project is a console app. Behind the scenes when the project is run, BenchmarkDotNet builds and outputs this test project into a temporary working directory. Then it creates a separate process where all the benchmarking measurements are done.

BenchmarkDotNet is customizable. BenchmarkDotNet tests are set up similarly to unit tests, using attributes. Benchmarks can be parametrized. There are global and iteration [setup and cleanup](https://benchmarkdotnet.org/articles/features/setup-and-cleanup.html) methods that can be used to setup the environment before running actual tests. The number of times that a benchmark should run can be customized, although it is recommended to use the defaults, as the BenchmarkDotNet does it's own pre-processing to find the optimal number of runs. [How it works](https://benchmarkdotnet.org/articles/guides/how-it-works.html) guide describes the steps that BenchmarkDotNet takes to run the benchmarks. BenchmarkDotNet supports running tests on [multiple frameworks](https://benchmarkdotnet.org/articles/configs/toolchains.html#multiple-frameworks-support).

Expand Down Expand Up @@ -73,7 +73,7 @@ The tests cover common MSAL usage scenarios.
- A simple scenario few cache entries with few tokens in each (ex. few resources accessed for each tenant or by one user).
- The more common scenario is many cache entries with few tokens in each. This also shows that the number of cache entries / keys doesn't affect the performance much (besides internal .NET operations) because the filtering operations to find a token are done only on the specific cache entry, which is retrieved in O(n) time.
- A less common scenario is a lot of tokens per cache entry (generally for client credential app tokens).
- **Enabled token cache serialization** - whether cache serialization is enabled or disabled (as described in [docs](https://docs.microsoft.com/en-us/azure/active-directory/develop/msal-net-token-cache-serialization?tabs=aspnetcore#monitor-cache-hit-ratios-and-cache-performance)). When disabled MSAL uses internal in-memory cache, pre-populated with tokens as described above. When enabled, MSAL pre-populates and serializes into a .NET Memory Cache structure. The serialization is what adds the perf hit between these two options.
- **Enabled token cache serialization** - whether cache serialization is enabled or disabled (as described in [docs](/azure/active-directory/develop/msal-net-token-cache-serialization?tabs=aspnetcore#monitor-cache-hit-ratios-and-cache-performance)). When disabled MSAL uses internal in-memory cache, pre-populated with tokens as described above. When enabled, MSAL pre-populates and serializes into a .NET Memory Cache structure. The serialization is what adds the perf hit between these two options.

## Improvements and test results

Expand Down

0 comments on commit 1763efc

Please sign in to comment.