chombo-discharge
Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
Timer Class Reference

Class which is used for run-time monitoring of events. More...

#include <CD_Timer.H>

Public Types

using Clock = std::chrono::steady_clock
 Clock implements.
 
using TimePoint = std::chrono::steady_clock::time_point
 Point in time.
 
using Duration = std::chrono::duration< Real >
 Duration in seconds.
 

Public Member Functions

 Timer ()=default
 Default constructor. This creates a timer without any timer events and without a name.
 
 Timer (const std::string a_process)
 Default constructor. This creates a timer without any timer events and without a name.
 
 ~Timer ()
 Destructor.
 
 Timer (const Timer &a_other)=default
 Copy construction. More...
 
Timeroperator= (const Timer &a_other)=default
 Copy assignement. More...
 
void startEvent (const std::string a_event) noexcept
 Start an event. More...
 
void stopEvent (const std::string a_event) noexcept
 Stop an event. More...
 
void eventReport (std::ostream &a_outputStream, const bool a_localReportOnly=false) const noexcept
 Print all timed events to cout. More...
 
void writeReportToFile (const std::string a_fileName) const noexcept
 Print all timed events to a file. More...
 
void clear () noexcept
 Clear all events.
 

Static Public Member Functions

static Real wallClock ()
 Static function which returns the time (in seconds) between now and an arbitrary time in the past.
 

Protected Types

enum  EventFields { StoppedEvent = 0 , StartClock = 1 , ElapsedTime = 2 }
 Enum for indexing tuple. A rare case of where unscoped enums are useful.
 

Protected Member Functions

void printReportHeader (std::ostream &a_outputStream) const noexcept
 Print report header.
 
void printReportTail (std::ostream &a_outputStream, const std::pair< Real, Real > a_elapsedTime) const noexcept
 Print report tail.
 
std::pair< Real, Real > computeTotalElapsedTime (const bool a_localReportOnly) const noexcept
 Compute the total time for all finished events. More...
 

Protected Attributes

std::string m_processName
 Process name. Used for input/output.
 
std::map< std::string, std::tuple< bool, TimePoint, Duration > > m_events
 Timer events. First entry is the name of the event. More...
 

Detailed Description

Class which is used for run-time monitoring of events.

Constructor & Destructor Documentation

◆ Timer()

Timer::Timer ( const Timer a_other)
default

Copy construction.

Parameters
[in]a_otherOther Timer

Member Function Documentation

◆ computeTotalElapsedTime()

std::pair< Real, Real > Timer::computeTotalElapsedTime ( const bool  a_localReportOnly) const
inlineprotectednoexcept

Compute the total time for all finished events.

Returns
First entry is the local time. Second entry is the global time.

◆ eventReport()

void Timer::eventReport ( std::ostream &  a_outputStream,
const bool  a_localReportOnly = false 
) const
inlinenoexcept

Print all timed events to cout.

This routine prints a header, the timing report for the various event, and a tail. All events are included but unfinished ones are not counted towards the elapsed time.

Parameters
[in]a_localReportOnlyIf true, no reduction over mpi

◆ operator=()

Timer& Timer::operator= ( const Timer a_other)
default

Copy assignement.

Parameters
[in]a_otherOther Timer

◆ startEvent()

void Timer::startEvent ( const std::string  a_event)
inlinenoexcept

Start an event.

Parameters
[in]a_eventEvent name
Note
This will give a run-time error if the event has already been started (i.e. startEvent(a_event) has not been called prior).

◆ stopEvent()

void Timer::stopEvent ( const std::string  a_event)
inlinenoexcept

Stop an event.

Parameters
[in]a_eventEvent name
Note
This will give a run-time error if the event has not already been started (i.e. startEvent(a_event) has not been called prior).

◆ writeReportToFile()

void Timer::writeReportToFile ( const std::string  a_fileName) const
inlinenoexcept

Print all timed events to a file.

This routine prints a header row consisting of the event names. The remaining rows are the timings for the various ranks.

Parameters
[in]a_localReportOnlyIf true, no reduction over mpi

Member Data Documentation

◆ m_events

std::map<std::string, std::tuple<bool, TimePoint, Duration> > Timer::m_events
protected

Timer events. First entry is the name of the event.

The second is the identifier for the event


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