This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH, OBVIOUS] Do not divide by zero in analyze_brprob.py


Hi.

Following trivial patch is necessary to preserve division by zero.

Installed as r238590.

Thanks,
Martin
>From 990fd22bfe222a5f66fa780d5b596b7a948ea267 Mon Sep 17 00:00:00 2001
From: marxin <mliska@suse.cz>
Date: Thu, 21 Jul 2016 14:49:30 +0200
Subject: [PATCH] Do not divide by zero in analyze_brprob.py

contrib/ChangeLog:

2016-07-21  Martin Liska  <mliska@suse.cz>

	* analyze_brprob.py: If there's no loop, do not calculate
	average number of loop iterations.
---
 contrib/analyze_brprob.py | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/contrib/analyze_brprob.py b/contrib/analyze_brprob.py
index c276d81..c083d2b 100755
--- a/contrib/analyze_brprob.py
+++ b/contrib/analyze_brprob.py
@@ -149,12 +149,13 @@ class Profile:
              percentage(v.hits, v.count), percentage(v.fits, v.count),
              v.count, v.count_formatted(), percentage(v.count, self.count_max()) ))
 
-        print ('\nLoop count: %d' % len(self.niter_vector)),
-        print('  avg. # of iter: %.2f' % average(self.niter_vector))
-        print('  median # of iter: %.2f' % median(self.niter_vector))
-        for v in [1, 5, 10, 20, 30]:
-            cut = 0.01 * v
-            print('  avg. (%d%% cutoff) # of iter: %.2f' % (v, average_cutoff(self.niter_vector, cut)))
+        if len(self.niter_vector) > 0:
+            print ('\nLoop count: %d' % len(self.niter_vector)),
+            print('  avg. # of iter: %.2f' % average(self.niter_vector))
+            print('  median # of iter: %.2f' % median(self.niter_vector))
+            for v in [1, 5, 10, 20, 30]:
+                cut = 0.01 * v
+                print('  avg. (%d%% cutoff) # of iter: %.2f' % (v, average_cutoff(self.niter_vector, cut)))
 
 parser = argparse.ArgumentParser()
 parser.add_argument('dump_file', metavar = 'dump_file', help = 'IPA profile dump file')
-- 
2.9.0


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]