*/
void print_summary () const;
+ /**
+ * By calling this function, all output
+ * can be disabled. This function
+ * together with enable_output() can be
+ * useful if one wants to control the
+ * output in a flexible way without
+ * putting a lot of <tt>if</tt> clauses
+ * in the program.
+ */
+ void disable_output ();
+
+ /**
+ * This function re-enables output of
+ * this class if it was previously
+ * disabled with disable_output(). This
+ * function together with
+ * disable_output() can be useful if
+ * one wants to control the output in a
+ * flexible way without putting a lot
+ * of <tt>if</tt> clauses in the
+ * program.
+ */
+ void enable_output ();
+
private:
/**
* A timer object for the overall
*/
ConditionalOStream out_stream;
+ /**
+ * A boolean variable that sets whether
+ * output of this class is currently on
+ * or off.
+ */
+ bool output_is_enabled;
+
/**
* A list of the sections that
* have been entered and not
* class gives reasonable results even
* when used with several threads.
*/
-
Threads::ThreadMutex mutex;
};
:
output_frequency (output_frequency),
output_type (output_type),
- out_stream (stream, true)
+ out_stream (stream, true),
+ output_is_enabled (true)
#ifdef DEAL_II_COMPILER_SUPPORTS_MPI
, mpi_communicator (MPI_COMM_SELF)
#endif
:
output_frequency (output_frequency),
output_type (output_type),
- out_stream (stream)
+ out_stream (stream),
+ output_is_enabled (true)
#ifdef DEAL_II_COMPILER_SUPPORTS_MPI
, mpi_communicator (MPI_COMM_SELF)
#endif
:
output_frequency (output_frequency),
output_type (output_type),
- out_stream (stream, true),
+ out_stream (stream, true),
+ output_is_enabled (true),
mpi_communicator (mpi_communicator)
{}
output_frequency (output_frequency),
output_type (output_type),
out_stream (stream),
+ output_is_enabled (true),
mpi_communicator (mpi_communicator)
{}
while (active_sections.size() > 0)
exit_section();
- if (output_frequency != every_call)
+ if (output_frequency != every_call && output_is_enabled == true)
print_summary();
}
void
TimerOutput::exit_section (const std::string §ion_name)
{
+ Assert (active_sections.size() > 0,
+ ExcMessage("Cannot exit any section because none has been entered!"));
+
Threads::ThreadMutex::ScopedLock lock (mutex);
if (section_name != "")
// in case we have to print out
// something, do that here...
- if (output_frequency != summary)
+ if (output_frequency != summary && output_is_enabled == true)
{
std::string output_time;
std::ostringstream cpu;
}
+
+void
+TimerOutput::disable_output ()
+{
+ output_is_enabled = false;
+}
+
+
+
+void
+TimerOutput::enable_output ()
+{
+ output_is_enabled = true;
+}
+
+
DEAL_II_NAMESPACE_CLOSE