ThunderEgg  1.0.0
ThunderEgg::Timer Class Reference

Class for keeping track of parallel timings. More...

#include <Timer.h>

Public Member Functions

 Timer (const Communicator &comm)
 Construct a new empty Timer object.
 
 ~Timer ()
 Destruct a Timer object.
 
void start (const std::string &name)
 Start a new timing. More...
 
void stop (const std::string &name)
 Stop a timing. More...
 
void addDomain (int domain_id, tpl::nlohmann::json domain)
 add a domain to to timer More...
 
void startDomainTiming (int domain_id, const std::string &name)
 Start a new Domain associated timing. More...
 
void stopDomainTiming (int domain_id, const std::string &name)
 Stop a Domain associated timing. More...
 
void startPatchTiming (int patch_id, int domain_id, const std::string &name)
 Start a new Domain associated timing. More...
 
void stopPatchTiming (int patch_id, int domain_id, const std::string &name)
 Stop a Domain associated timing. More...
 
void addIntInfo (const std::string &name, int info)
 Add information to a timing. More...
 
void addDoubleInfo (const std::string &name, double info)
 Add information to a timing. More...
 
void saveToFile (const std::string &filename) const
 Save a json representation of the timer to the file. This is collective over all processes. More...
 

Friends

std::ostream & operator<< (std::ostream &os, const Timer &timer)
 ostream operator for Timer, this is collective for all ranks, will only output on rank 0 More...
 
void to_json (tpl::nlohmann::json &j, const Timer &timer)
 Convert a timer to a json serialization, this is collective over all processes will only result in a json object for rank 0, will be null for all other ranks. More...
 

Detailed Description

Class for keeping track of parallel timings.

This class will keep track of timings and present them in a nice format.

This class also keeps track of nested timings. For following

    timer.start("A");
    timer.start("B");
    timer.stop("B");
    timer.stop("A");

outputs

    A
    -
    time (sec): 1.0


    A -> B
    ------
    time(sec):

Member Function Documentation

◆ addDomain()

void ThunderEgg::Timer::addDomain ( int  domain_id,
tpl::nlohmann::json  domain 
)

add a domain to to timer

Parameters
domain_idthe id of the domain
domainthe domain
Exceptions
RuntimerErrorif domain with same id was already added

◆ addDoubleInfo()

void ThunderEgg::Timer::addDoubleInfo ( const std::string &  name,
double  info 
)

Add information to a timing.

Has to be called after start is called for the timing and before stop is called for the timing

Parameters
namethe name of the information
infothe value of the information
Exceptions
RuntimeErrorthere is no timing to add information to, or if adding double information to existing int information

◆ addIntInfo()

void ThunderEgg::Timer::addIntInfo ( const std::string &  name,
int  info 
)

Add information to a timing.

Has to be called after start is called for the timing and before stop is called for the timing

Parameters
namethe name of the information
infothe value of the information
Exceptions
RuntimeErrorthere is no timing to add information to, or if adding int information to existing double information

◆ saveToFile()

void ThunderEgg::Timer::saveToFile ( const std::string &  filename) const

Save a json representation of the timer to the file. This is collective over all processes.

Parameters
filenamethe file to save to
Exceptions
RuntimeErroron rank 0 if the file cannot be opened for writing.

◆ start()

void ThunderEgg::Timer::start ( const std::string &  name)

Start a new timing.

Parameters
namethe name of the timing

◆ startDomainTiming()

void ThunderEgg::Timer::startDomainTiming ( int  domain_id,
const std::string &  name 
)

Start a new Domain associated timing.

Parameters
domain_idthe id of the Domain
namethe name of the timing
Exceptions
RuntimerErrorif domain was not added with addDomain

◆ startPatchTiming()

void ThunderEgg::Timer::startPatchTiming ( int  patch_id,
int  domain_id,
const std::string &  name 
)

Start a new Domain associated timing.

Parameters
patch_idthe id of the PatchInfo
domain_idthe id of the Domain
namethe name of the timing
Exceptions
RuntimerErrorif domain was not added with addDomain

◆ stop()

void ThunderEgg::Timer::stop ( const std::string &  name)

Stop a timing.

Parameters
namethe name of the timing
Exceptions
TimerExceptionif the name does not match the name of the last started timing.

◆ stopDomainTiming()

void ThunderEgg::Timer::stopDomainTiming ( int  domain_id,
const std::string &  name 
)

Stop a Domain associated timing.

Parameters
domain_idthe id of the Domain
namethe name of the timing
Exceptions
RuntimeErrorif the domain id and name does not match the name of the last started timing.

◆ stopPatchTiming()

void ThunderEgg::Timer::stopPatchTiming ( int  patch_id,
int  domain_id,
const std::string &  name 
)

Stop a Domain associated timing.

Parameters
patch_idthe id of the PatchInfo
domain_idthe id of the Domain
namethe name of the timing
Exceptions
RuntimeErrorif the patch id, domain id and name does not match the name of the last started timing.

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const Timer timer 
)
friend

ostream operator for Timer, this is collective for all ranks, will only output on rank 0

Parameters
osthe stream
timerthe timer
Returns
std::ostream& the stream

◆ to_json

void to_json ( tpl::nlohmann::json &  j,
const Timer timer 
)
friend

Convert a timer to a json serialization, this is collective over all processes will only result in a json object for rank 0, will be null for all other ranks.

Parameters
jresulting json
timerthe timer

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