Fix the -time-passes option to not print NaN when there is zero execution time
authorChris Lattner <sabre@nondot.org>
Mon, 19 Aug 2002 15:43:33 +0000 (15:43 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 19 Aug 2002 15:43:33 +0000 (15:43 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3382 91177308-0d34-0410-b5e6-96231b3b80d8

lib/VMCore/Pass.cpp

index 106d70b31aaece26debdd2fd5c297e3459d716d9..28244518df78e5619884dedd6e7079d7015b5765 100644 (file)
@@ -122,13 +122,20 @@ void TimeRecord::passEnd(const TimeRecord &T) {
   MaxRSS      = std::max(MaxRSS, RSSTemp);
 }
 
+static void printVal(double Val, double Total) {
+  if (Total < 1e-7)   // Avoid dividing by zero...
+    fprintf(stderr, "        -----    ");
+  else
+    fprintf(stderr, "  %7.4f (%5.1f%%)", Val, Val*100/Total);
+}
+
 void TimeRecord::print(const char *PassName, const TimeRecord &Total) const {
-  fprintf(stderr, 
-          "  %7.4f (%5.1f%%)  %7.4f (%5.1f%%)  %7.4f (%5.1f%%)  %7.4f (%5.1f%%)  ",
-          UserTime  , UserTime  *100/Total.UserTime,
-          SystemTime, SystemTime*100/Total.SystemTime,
-          UserTime+SystemTime, (UserTime+SystemTime)*100/(Total.UserTime+Total.SystemTime),
-          Elapsed   , Elapsed   *100/Total.Elapsed);
+  printVal(UserTime, Total.UserTime);
+  printVal(SystemTime, Total.SystemTime);
+  printVal(UserTime+SystemTime, Total.UserTime+Total.SystemTime);
+  printVal(Elapsed, Total.Elapsed);
+  
+  fprintf(stderr, "  ");
 
   if (Total.MaxRSS)
     std::cerr << MaxRSS << "\t";