From: Ian Romanick <ian.d.roman...@intel.com>

Previously an absolute value less than 0.0001 would be printed as 0.00%.

Signed-off-by: Ian Romanick <ian.d.roman...@intel.com>
---
 report.py | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/report.py b/report.py
index 72752c1..175a953 100755
--- a/report.py
+++ b/report.py
@@ -34,10 +34,18 @@ def get_results(filename):
     return results
 
 
+def format_percent(frac):
+    """Converts a factional value (typically 0.0 to 1.0) to a string as a 
percentage"""
+    if abs(frac) > 0.0 and abs(frac) < 0.0001:
+        return "<.01%"
+    else:
+        return "{:.2f}%".format(frac * 100)
+
+
 def get_delta(b, a):
     if b != 0 and a != 0:
         frac = float(a) / float(b) - 1.0
-        return ' ({:.2f}%)'.format(frac * 100.0)
+        return ' ({})'.format(format_percent(frac))
     else:
         return ''
 
-- 
2.9.5

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to