From 9765d148c440e9f91b45d978111316d626228199 Mon Sep 17 00:00:00 2001 From: Mike Harder Date: Tue, 9 Feb 2021 13:14:10 -0800 Subject: [PATCH] [Perf] Prevent divide-by-zero for incomplete threads (#18512) --- common/Perf/Azure.Test.Perf/PerfProgram.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/common/Perf/Azure.Test.Perf/PerfProgram.cs b/common/Perf/Azure.Test.Perf/PerfProgram.cs index 902de3a3b69d..8c1a904dc69d 100644 --- a/common/Perf/Azure.Test.Perf/PerfProgram.cs +++ b/common/Perf/Azure.Test.Perf/PerfProgram.cs @@ -25,7 +25,9 @@ public static class PerfProgram 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(); + private static double OperationsPerSecond => _completedOperations.Zip(_lastCompletionTimes, + (operations, time) => operations > 0 ? (operations / time.TotalSeconds) : 0) + .Sum(); public static async Task Main(Assembly assembly, string[] args) {