diff options
author | Pierre Moreau <pierre.morrow@free.fr> | 2017-10-08 11:08:46 +0200 |
---|---|---|
committer | Ilia Mirkin <imirkin@alum.mit.edu> | 2017-11-04 14:20:50 -0400 |
commit | 1ef486a5a8c8cb8ae29e7ae672e7c5f0c7b30210 (patch) | |
tree | b18cb69bfc8e88a60911af50d456e2b5218efb2f /nv-report.py | |
parent | eca76ad4e2c3e05d5c88a129a402b7300f16f247 (diff) |
nv-report: Avoid division-by-zero in diff() function
Signed-off-by: Pierre Moreau <pierre.morrow@free.fr>
Diffstat (limited to 'nv-report.py')
-rw-r--r-- | nv-report.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/nv-report.py b/nv-report.py index abd6110..724c662 100644 --- a/nv-report.py +++ b/nv-report.py @@ -62,7 +62,12 @@ def analyze(fname): return stats 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): # Count up each of the metrics in the before and after, and |