diff --git a/common/Perf/Azure.Test.Perf/PerfProgram.cs b/common/Perf/Azure.Test.Perf/PerfProgram.cs index 3d411e831527..6cbc5437e5ec 100644 --- a/common/Perf/Azure.Test.Perf/PerfProgram.cs +++ b/common/Perf/Azure.Test.Perf/PerfProgram.cs @@ -24,6 +24,9 @@ public static class PerfProgram private static List[] _correctedLatencies; private static Channel<(TimeSpan, Stopwatch)> _pendingOperations; + private static int CompletedOperations => _completedOperations.Sum(); + private static double OperationsPerSecond => _completedOperations.Zip(_lastCompletionTimes, (operations, time) => (operations / time.TotalSeconds)).Sum(); + public static async Task Main(Assembly assembly, string[] args) { var testTypes = assembly.ExportedTypes @@ -215,13 +218,15 @@ private static async Task RunTestsAsync(IPerfTest[] tests, PerfOptions options, using var progressStatusCts = new CancellationTokenSource(); var progressStatusThread = PerfStressUtilities.PrintStatus( $"=== {title} ===" + Environment.NewLine + - "Current\t\tTotal", + "Current\t\tTotal\t\tAverage", () => { - var totalCompleted = _completedOperations.Sum(); + var totalCompleted = CompletedOperations; var currentCompleted = totalCompleted - lastCompleted; + var averageCompleted = OperationsPerSecond; + lastCompleted = totalCompleted; - return currentCompleted + "\t\t" + totalCompleted; + return $"{currentCompleted}\t\t{totalCompleted}\t\t{averageCompleted:F0}"; }, newLine: true, progressStatusCts.Token, @@ -273,12 +278,12 @@ private static async Task RunTestsAsync(IPerfTest[] tests, PerfOptions options, Console.WriteLine("=== Results ==="); - var totalOperations = _completedOperations.Sum(); - var operationsPerSecond = _completedOperations.Zip(_lastCompletionTimes, (operations, time) => (operations / time.TotalSeconds)).Sum(); + var totalOperations = CompletedOperations; + var operationsPerSecond = OperationsPerSecond; var secondsPerOperation = 1 / operationsPerSecond; var weightedAverageSeconds = totalOperations / operationsPerSecond; - Console.WriteLine($"Completed {totalOperations} operations in a weighted-average of {weightedAverageSeconds:N2}s " + + Console.WriteLine($"Completed {totalOperations:N0} operations in a weighted-average of {weightedAverageSeconds:N2}s " + $"({operationsPerSecond:N2} ops/s, {secondsPerOperation:N3} s/op)"); Console.WriteLine();