TimerOutput Class Reference
[Utility functions and classes]

List of all members.

Classes

struct  Section

Public Types

enum  OutputFrequency { every_call, summary, every_call_and_summary }
enum  OutputType { cpu_times, wall_times, cpu_and_wall_times }

Public Member Functions

 TimerOutput (std::ostream &stream, const enum OutputFrequency output_frequency, const enum OutputType output_type)
 TimerOutput (ConditionalOStream &stream, const enum OutputFrequency output_frequency, const enum OutputType output_type)
 TimerOutput (MPI_Comm mpi_comm, std::ostream &stream, const enum OutputFrequency output_frequency, const enum OutputType output_type)
 TimerOutput (MPI_Comm mpi_comm, ConditionalOStream &stream, const enum OutputFrequency output_frequency, const enum OutputType output_type)
 ~TimerOutput ()
void enter_section (const std::string &section_name)
void exit_section (const std::string &section_name=std::string())
void print_summary ()

Public Attributes

enum TimerOutput::OutputFrequency output_frequency
enum TimerOutput::OutputType output_type

Private Attributes

Timer timer_all
std::map< std::string, Sectionsections
ConditionalOStream out_stream
std::list< std::string > active_sections
MPI_Comm mpi_communicator
Threads::ThreadMutex mutex

Detailed Description

This class can be used to generate formatted output from time measurements of different subsections in a program. It is possible to create several sections that perform certain aspects of the program. A section can be entered several times. By changing the options in OutputFrequency and OutputType, the user can choose whether output should be generated every time a section is joined or just in the end of the program. Moreover, it is possible to show CPU times, wall times or both.

TODO: Write a more extensive documentation.

Author:
M. Kronbichler, 2009.

Member Enumeration Documentation

Sets whether to generate output every time we exit a section, just in the end, or both.

Enumerator:
every_call 
summary 
every_call_and_summary 

Sets whether to show CPU times, wall times, or both CPU and wall times.

Enumerator:
cpu_times 
wall_times 
cpu_and_wall_times 

Constructor & Destructor Documentation

TimerOutput::TimerOutput ( std::ostream &  stream,
const enum OutputFrequency  output_frequency,
const enum OutputType  output_type 
)

Constructor that takes std::cout as output stream.

TimerOutput::TimerOutput ( ConditionalOStream stream,
const enum OutputFrequency  output_frequency,
const enum OutputType  output_type 
)

Constructor that takes a ConditionalOStream to write output to.

TimerOutput::TimerOutput ( MPI_Comm  mpi_comm,
std::ostream &  stream,
const enum OutputFrequency  output_frequency,
const enum OutputType  output_type 
)

Constructor that takes an MPI communicator as input. A timer constructed this way will sum up the CPU times over all processors in the MPI network for calculating the CPU time.

Meant for using std::cout as output stream.

TimerOutput::TimerOutput ( MPI_Comm  mpi_comm,
ConditionalOStream stream,
const enum OutputFrequency  output_frequency,
const enum OutputType  output_type 
)

Constructor that takes an MPI communicator as input. A timer constructed this way will sum up the CPU times over all processors in the MPI network for calculating the CPU time.

Constructor that takes a ConditionalOStream to write output to.

TimerOutput::~TimerOutput (  ) 

Destructor. Calls print_summary() in case the option for writing the summary output is set.


Member Function Documentation

void TimerOutput::enter_section ( const std::string &  section_name  ) 

Open a section by given a string name of it. In case the name already exists, that section is done once again.

void TimerOutput::exit_section ( const std::string &  section_name = std::string()  ) 

Leave a section. If no name is given, the last section that was entered is left.

void TimerOutput::print_summary (  ) 

Print a formatted table that summarizes the time consumed in the various sections.


Member Data Documentation

Sets whether to generate output every time we exit a section, just in the end, or both.

Sets whether to show CPU times, wall times, or both CPU and wall times.

A timer object for the overall run time. If we are using MPI, this timer also accumulates over all MPI processes.

std::map<std::string, Section> TimerOutput::sections [private]

A list of all the sections and their information.

The stream object to which we are to output.

std::list<std::string> TimerOutput::active_sections [private]

A list of the sections that have been entered and not exited. The list is kept in the order in which sections have been entered, but elements may be removed in the middle if an argument is given to the exit_section() function.

MPI_Comm TimerOutput::mpi_communicator [private]

Store whether the timer is presently running.

A lock that makes sure that this class gives reasonable results even when used with several threads.


The documentation for this class was generated from the following file:

deal.II documentation generated on Mon Nov 23 22:58:14 2009 by doxygen 1.6.1