adamantine
Public Member Functions | Private Attributes | List of all members
adamantine::Timer Class Reference

#include <Timer.hh>

Public Member Functions

 Timer ()=default
 
 Timer (MPI_Comm communicator, std::string const &section)
 
void start ()
 
void stop ()
 
void reset ()
 
void print ()
 
boost::chrono::process_real_cpu_clock::duration get_elapsed_time ()
 

Private Attributes

MPI_Comm _communicator
 
std::string _section
 
boost::chrono::process_cpu_clock _clock
 
boost::chrono::process_cpu_clock::time_point _t_start
 
boost::chrono::process_cpu_clock::duration _elapsed_time
 

Detailed Description

This class measures the time spend in a given section by the rank 0 process. This class does not use any MPI_Barrier to synchronize the timer among all the processors.

Definition at line 21 of file Timer.hh.

Constructor & Destructor Documentation

◆ Timer() [1/2]

adamantine::Timer::Timer ( )
default

Default constructor.

◆ Timer() [2/2]

adamantine::Timer::Timer ( MPI_Comm  communicator,
std::string const &  section 
)

Constructor. The string section is used when the timing is output.

Definition at line 11 of file Timer.cc.

Member Function Documentation

◆ get_elapsed_time()

boost::chrono::process_real_cpu_clock::duration adamantine::Timer::get_elapsed_time ( )

Return the current elapsed time.

Definition at line 36 of file Timer.cc.

◆ print()

void adamantine::Timer::print ( )

Print the name of the section and the elapsed time.

Definition at line 23 of file Timer.cc.

◆ reset()

void adamantine::Timer::reset ( )

Reset to zero the store duration.

Definition at line 21 of file Timer.cc.

◆ start()

void adamantine::Timer::start ( )

Start the clock.

Definition at line 17 of file Timer.cc.

◆ stop()

void adamantine::Timer::stop ( )

Stop the clock. If the clock has already been started and stopped before the new duration will be added to the previous one.

Definition at line 19 of file Timer.cc.

Member Data Documentation

◆ _clock

boost::chrono::process_cpu_clock adamantine::Timer::_clock
private

Definition at line 63 of file Timer.hh.

◆ _communicator

MPI_Comm adamantine::Timer::_communicator
private

Definition at line 61 of file Timer.hh.

◆ _elapsed_time

boost::chrono::process_cpu_clock::duration adamantine::Timer::_elapsed_time
private

Store the elapsed time in milliseconds nds

Definition at line 68 of file Timer.hh.

◆ _section

std::string adamantine::Timer::_section
private

Definition at line 62 of file Timer.hh.

◆ _t_start

boost::chrono::process_cpu_clock::time_point adamantine::Timer::_t_start
private

Definition at line 64 of file Timer.hh.