]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Right-align wallclock time in TimerOutput. Reset original alignment flags at the...
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 28 Nov 2011 23:12:16 +0000 (23:12 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 28 Nov 2011 23:12:16 +0000 (23:12 +0000)
git-svn-id: https://svn.dealii.org/trunk@24776 0785d39b-7218-0410-832d-ea1e28bc413d

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

index 2f578603f69eb8319ea812dc0bdfa42789abb690..7cd09605fe96235f1d456abe9cf110e4ed90d376 100644 (file)
@@ -73,6 +73,12 @@ enabled due to a missing include file in file
 <h3>Specific improvements</h3>
 
 <ol>
+<li> Fixed: The TimerOutput class set the alignment of output to right-aligned
+under some circumstances, but didn't reset this to the previous value at the
+end of output. This is now fixed.
+<br>
+(Wolfgang Bangerth, 2011/11/28)
+
 <li> New: The copy constructor of the SparseMatrixEZ function now works
 (rather than throwing an exception) if the copied matrix has size zero.
 This is in accordance to the other matrix classes.
index 0ecb790c32512d8e6b84d5675c119e02ef327f94..26b916b81fb2ca071e4204be1ecc600586dbeb7a 100644 (file)
@@ -150,7 +150,7 @@ double Timer::operator() () const
 
       const double running_time = dtime - start_time + dtime_children
                                  - start_time_children + cumulative_time;
-      
+
       if (Utilities::System::job_supports_mpi())
                                   // in case of MPI, need to get the time
                                   // passed by summing the time over all
@@ -369,8 +369,9 @@ TimerOutput::print_summary () const
                                   // precision and width of output
                                   // below. store the old values so we
                                   // can restore it later on
-  std::streamsize old_precision = out_stream.get_stream().precision ();
-  std::streamsize old_width     = out_stream.get_stream().width ();
+  const std::istream::fmtflags old_flags = out_stream.get_stream().flags();
+  const std::streamsize    old_precision = out_stream.get_stream().precision ();
+  const std::streamsize    old_width     = out_stream.get_stream().width ();
 
                                   // in case we want to write CPU times
   if (output_type != wall_times)
@@ -396,8 +397,7 @@ TimerOutput::print_summary () const
                 << "+---------------------------------------------+------------"
                 << "+------------+\n"
                 << "| Total CPU time elapsed since start          |";
-      out_stream << std::setw(10);
-      out_stream << std::setprecision(3);
+      out_stream << std::setw(10) << std::setprecision(3) << std::right;
       out_stream << total_cpu_time << "s |            |\n";
       out_stream << "|                                             |            "
                 << "|            |\n";
@@ -464,8 +464,7 @@ TimerOutput::print_summary () const
                 << "+---------------------------------------------+------------"
                 << "+------------+\n"
                 << "| Total wallclock time elapsed since start    |";
-      out_stream << std::setw(10);
-      out_stream << std::setprecision(3);
+      out_stream << std::setw(10) << std::setprecision(3) << std::right;
       out_stream << total_wall_time << "s |            |\n";
       out_stream << "|                                             |            "
                 << "|            |\n";
@@ -512,6 +511,7 @@ TimerOutput::print_summary () const
                                   // restore previous precision and width
   out_stream.get_stream().precision (old_precision);
   out_stream.get_stream().width (old_width);
+  out_stream.get_stream().flags (old_flags);
 }
 
 

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.