Reference documentation for deal.II version 9.0.0
|
#include <deal.II/base/timer.h>
Classes | |
struct | ClockMeasurements |
Public Member Functions | |
Timer () | |
Timer (MPI_Comm mpi_communicator, const bool sync_lap_times=false) | |
const Utilities::MPI::MinMaxAvg & | get_data () const |
const Utilities::MPI::MinMaxAvg & | get_last_lap_wall_time_data () const |
const Utilities::MPI::MinMaxAvg & | get_total_data () const |
const Utilities::MPI::MinMaxAvg & | get_accumulated_wall_time_data () const |
template<class StreamType > | |
void | print_data (StreamType &stream) const |
template<class StreamType > | |
void | print_last_lap_wall_time_data (StreamType &stream) const |
template<class StreamType > | |
void | print_total_data (StreamType &stream) const |
template<class StreamType > | |
void | print_accumulated_wall_time_data (StreamType &stream) const |
void | start () |
double | stop () |
void | reset () |
void | restart () |
double | operator() () const |
double | wall_time () const |
double | last_wall_time () const |
double | cpu_time () const |
double | last_cpu_time () const |
double | get_lap_time () const |
Private Types | |
typedef std::chrono::steady_clock | wall_clock_type |
typedef CPUClock | cpu_clock_type |
Private Attributes | |
ClockMeasurements< wall_clock_type > | wall_times |
ClockMeasurements< cpu_clock_type > | cpu_times |
bool | running |
MPI_Comm | mpi_communicator |
bool | sync_lap_times |
Utilities::MPI::MinMaxAvg | last_lap_wall_time_data |
Utilities::MPI::MinMaxAvg | accumulated_wall_time_data |
The Timer class provides a way to measure both the amount of wall time (i.e., the amount of time elapsed on a wall clock) and the amount of CPU time that certain sections of an application have used. This class also offers facilities for synchronizing the elapsed time across an MPI communicator.
The Timer class can be started and stopped several times. It stores both the amount of time elapsed over the last start-stop cycle, or lap, as well as the total time elapsed over all laps. Here is an example:
Alternatively, you can also restart the timer instead of resetting it. The times between successive calls to start() and stop() (i.e., the laps) will then be accumulated. The usage of this class is also explained in the step-28 tutorial program.
|
private |
|
private |
Timer::Timer | ( | ) |
Constructor. Sets the accumulated times at zero and calls Timer::start().
Timer::Timer | ( | MPI_Comm | mpi_communicator, |
const bool | sync_lap_times = false |
||
) |
Constructor specifying that CPU times should be summed over the given communicator. If sync_lap_times
is true
then the Timer will set the elapsed wall and CPU times over the last lap to their maximum values across the provided communicator. This synchronization is only performed if Timer::stop() is called before the timer is queried for time duration values.
This constructor calls Timer::start().
|
inline |
Return a reference to the data structure with global timing information for the last lap. This structure does not contain meaningful values until Timer::stop() has been called.
|
inline |
Return a reference to the data structure containing basic statistics on the last lap's wall time measured across all MPI processes in the given communicator. This structure does not contain meaningful values until Timer::stop() has been called.
|
inline |
Return a reference to the data structure containing basic statistics on the accumulated wall time measured across all MPI processes in the given communicator. This structure does not contain meaningful values until Timer::stop() has been called.
|
inline |
Return a reference to the data structure containing basic statistics on the accumulated wall time measured across all MPI processes in the given communicator. This structure does not contain meaningful values until Timer::stop() has been called.
|
inline |
Prints the data returned by get_data(), i.e. for the last lap, to the given stream.
|
inline |
Print the data returned by Timer::get_last_lap_wall_time_data() to the given stream.
|
inline |
Prints the data returned by get_total_data(), i.e. for the total run, to the given stream.
|
inline |
Print the data returned by Timer::get_accumulated_wall_time_data() to the given stream.
void Timer::start | ( | ) |
double Timer::stop | ( | ) |
Stop the timer. This updates the lap times and accumulated times. If sync_lap_times
is true
then the lap times are synchronized over all processors in the communicator (i.e., the lap times are set to the maximum lap time).
Return the accumulated CPU time in seconds.
void Timer::reset | ( | ) |
|
inline |
Equivalent to calling Timer::reset() followed by calling Timer::start().
double Timer::operator() | ( | ) | const |
Access to the current CPU time without stopping the timer. The elapsed time is returned in units of seconds.
double Timer::wall_time | ( | ) | const |
double Timer::last_wall_time | ( | ) | const |
double Timer::cpu_time | ( | ) | const |
Return the accumulated CPU time (including the current lap, if the timer is running) in seconds without stopping the timer.
If an MPI communicator is provided to the constructor then the returned value is the sum of all accumulated CPU times over all processors in the communicator.
double Timer::last_cpu_time | ( | ) | const |
double Timer::get_lap_time | ( | ) | const |
Return the wall time taken between the last start()/stop() call.
|
private |
|
private |
|
private |
|
private |
|
private |
Store whether or not the wall time and CPU time are synchronized across the communicator in Timer::start() and Timer::stop().
|
private |
|
private |
A structure for parallel wall time measurement that includes the minimum time recorded among all processes, the maximum time as well as the average time defined as the sum of all individual times divided by the number of MPI processes in the MPI_Comm for the total run time.