t/latency_percentiles: avoid division by zero
authorVincent Fu <vincent.fu@wdc.com>
Mon, 24 Feb 2020 14:20:46 +0000 (09:20 -0500)
committerVincent Fu <vincent.fu@wdc.com>
Mon, 24 Feb 2020 14:32:58 +0000 (09:32 -0500)
For the smallest latency durations, the actual and approximate values
should be exactly the same. Use this property to avoid a division by
zero when the actual latency value is zero.

Signed-off-by: Vincent Fu <vincent.fu@wdc.com>
t/latency_percentiles.py

index 0c8d0c194aa3a94c78664ba3e2455f68fdcc327d..5cdd49cf77bcb2fcde6d7b82b3f5966768fa04af 100755 (executable)
@@ -395,6 +395,11 @@ class FioLatTest():
         approximation   value of the bin used by fio to store a given latency
         actual          actual latency value
         """
+
+        # Avoid a division by zero. The smallest latency values have no error.
+        if actual == 0:
+            return approximation == 0
+
         delta = abs(approximation - actual) / actual
         return delta <= 1/128