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

[Perf] Include running average in per-second output #18071

Merged
merged 1 commit into from
Jan 20, 2021
Merged
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
17 changes: 11 additions & 6 deletions common/Perf/Azure.Test.Perf/PerfProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ public static class PerfProgram
private static List<TimeSpan>[] _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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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();

Expand Down