Commit 1ef486a5 authored by Pierre Moreau's avatar Pierre Moreau Committed by Ilia Mirkin

nv-report: Avoid division-by-zero in diff() function

Signed-off-by: Pierre Moreau's avatarPierre Moreau <pierre.morrow@free.fr>
parent eca76ad4
...@@ -62,7 +62,12 @@ def analyze(fname): ...@@ -62,7 +62,12 @@ def analyze(fname):
return stats return stats
def diff(a, b): def diff(a, b):
return "%d -> %d (%.2f%%)" % (a, b, b * 100. / a - 100.) percentage = 0.
if a != 0.:
percentage = b * 100. / a - 100.
elif b != 0.:
percentage = float('inf')
return "%d -> %d (%.2f%%)" % (a, b, percentage)
def main(argv): def main(argv):
# Count up each of the metrics in the before and after, and # Count up each of the metrics in the before and after, and
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment