Skip to content

Commit

Permalink
Improving the perf tests (#2072)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmprieur authored Feb 10, 2023
1 parent 51ef441 commit 80c32b1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ IEnumerable<Task> CreateTasks()
}

await Task.WhenAll(CreateTasks());

DisplayProgress(true);
}

/// <summary>
Expand Down Expand Up @@ -259,9 +261,14 @@ private void UpdateGlobalMetrics(Metrics localMetrics)
}
}

private void DisplayProgress()
private void DisplayProgress(bool summary=false)
{
var stringBuilder = new StringBuilder();
if (summary)
{
stringBuilder.AppendLine("------------------------------------------------------------------------");
stringBuilder.AppendLine("Summary");
}
stringBuilder.AppendLine("------------------------------------------------------------------------");
stringBuilder.AppendLine((string)$"Run time: {_processingStartTime} - {DateTime.Now} = {DateTime.Now - _processingStartTime}.");
stringBuilder.AppendLine((string)$"Total number of users: {_options.NumberOfUsersToTest} users from {_options.StartUserIndex} to {_options.StartUserIndex + _options.NumberOfUsersToTest - 1}.");
Expand All @@ -271,9 +278,11 @@ private void DisplayProgress()
stringBuilder.AppendLine((string)$"Loop: {_globalMetrics.TotalRequests / _options.NumberOfUsersToTest}");
stringBuilder.AppendLine((string)$"Total requests: {_globalMetrics.TotalRequests}.");
stringBuilder.AppendLine((string)$"Average request time: {_globalMetrics.AverageRequestTimeInMilliseconds:0.0000} ms.");
#if DEBUGGING_RUNNER
stringBuilder.AppendLine((string)$"Cache requests: {_globalMetrics.TotalTokensReturnedFromCache}.");
stringBuilder.AppendLine((string)$"Average cache time: {_globalMetrics.AverageMsalLookupTimeInMilliseconds:0.0000} ms.");
stringBuilder.AppendLine((string)$"AuthRequest failures: {_globalMetrics.TotalAcquireTokenFailures}. Generic failures: {_globalMetrics.TotalExceptions}.");
#endif
}

Console.WriteLine(stringBuilder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static IServiceCollection AddBenchmarkDistributedTokenCaches(this IServic

private static void RemoveExistingMemoryCache(IServiceCollection services)
{
ServiceDescriptor msalMemoryCacheService = services.First(s => s.ServiceType == typeof(IMsalTokenCacheProvider));
ServiceDescriptor? msalMemoryCacheService = services.FirstOrDefault(s => s.ServiceType == typeof(IMsalTokenCacheProvider));

if (msalMemoryCacheService != null)
{
Expand Down

0 comments on commit 80c32b1

Please sign in to comment.