Skip to content

Commit

Permalink
[Perf] Prevent divide-by-zero for incomplete threads (#18512)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeharder authored Feb 9, 2021
1 parent 3d55ff3 commit 9765d14
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion common/Perf/Azure.Test.Perf/PerfProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit 9765d14

Please sign in to comment.