From 9b37832d07f5ac674c1be0abdab298e7621ca97f Mon Sep 17 00:00:00 2001 From: Vincent Fu Date: Mon, 24 Feb 2020 09:20:46 -0500 Subject: [PATCH] t/latency_percentiles: avoid division by zero 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 --- t/latency_percentiles.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/t/latency_percentiles.py b/t/latency_percentiles.py index 0c8d0c19..5cdd49cf 100755 --- a/t/latency_percentiles.py +++ b/t/latency_percentiles.py @@ -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 -- 2.25.1