]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Only show TimerOutput percentages down to 0.1%. 3655/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Sat, 3 Dec 2016 13:57:03 +0000 (06:57 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Sat, 3 Dec 2016 13:57:03 +0000 (06:57 -0700)
Currently, if a TimerOutput section takes a very small fraction of the overall
time, we happily output in the last column that it took 6.5e-4%. This is not
only visually awkward compared to all of the other numbers that are not using
the e-04 notation, but also pretty pointless: nobody cares whether something took
that small a fraction of the overall time, and if they happen to do anyway: the
absolute amount of time is printed in the previous column.

Consequently, show everything that takes less than 0.1% of time as 0%.

doc/news/changes.h
source/base/timer.cc

index 0026c9cbfb424b4e5534013372653b5e7f2e1c98..4aeeeed31f826658d833691c1507831ffab57cb8 100644 (file)
@@ -459,6 +459,13 @@ inconvenience this causes.
 <h3>Specific improvements</h3>
 
 <ol>
+ <li> Changed: To improve readability, TimerOutput::print_summary()
+ now simply outputs "0%" if a particular section's time requires
+ less than 0.1 per cent of the overall run time.
+ <br>
+ (Wolfgang Bangerth, 2016/12/03)
+ </li>
+
  <li> Improved: The trait class has_vmult_add in linear_operators.h
  has been restricted to test if there is a vmult_add and a Tvmult_add
  method that takes two arguments. This check now also works with
index 2b29039f0daa8cd33718e369049659237bf2c087..767b085a4fdf88d1e203958995c945dd14e6817a 100644 (file)
@@ -533,9 +533,22 @@ TimerOutput::print_summary () const
           out_stream << std::setprecision(3);
           out_stream << i->second.total_cpu_time << "s |";
           out_stream << std::setw(10);
-          out_stream << std::setprecision(2);
           if (total_cpu_time != 0)
-            out_stream << i->second.total_cpu_time/total_cpu_time * 100 << "% |";
+            {
+              // if run time was less than 0.1%, just print a zero to avoid
+              // printing silly things such as "2.45e-6%". otherwise print
+              // the actual percentage
+              const double fraction = i->second.total_cpu_time/total_cpu_time;
+              if (fraction > 0.001)
+                {
+                  out_stream << std::setprecision(2);
+                  out_stream << fraction * 100;
+                }
+              else
+                out_stream << 0.0;
+
+              out_stream << "% |";
+            }
           else
             out_stream << 0.0 << "% |";
         }
@@ -591,11 +604,25 @@ TimerOutput::print_summary () const
           out_stream << std::setprecision(3);
           out_stream << i->second.total_wall_time << "s |";
           out_stream << std::setw(10);
-          out_stream << std::setprecision(2);
-          double value = i->second.total_wall_time/total_wall_time * 100;
-          if (!numbers::is_finite(value))
-            value = 0.0;
-          out_stream << value << "% |";
+
+          if (total_wall_time != 0)
+            {
+              // if run time was less than 0.1%, just print a zero to avoid
+              // printing silly things such as "2.45e-6%". otherwise print
+              // the actual percentage
+              const double fraction = i->second.total_wall_time/total_wall_time;
+              if (fraction > 0.001)
+                {
+                  out_stream << std::setprecision(2);
+                  out_stream << fraction * 100;
+                }
+              else
+                out_stream << 0.0;
+
+              out_stream << "% |";
+            }
+          else
+            out_stream << 0.0 << "% |";
         }
       out_stream << std::endl
                  << "+---------------------------------+-----------+"

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.