ThunderEgg
1.0.0
|
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... | |
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):
void ThunderEgg::Timer::addDomain | ( | int | domain_id, |
tpl::nlohmann::json | domain | ||
) |
add a domain to to timer
domain_id | the id of the domain |
domain | the domain |
RuntimerError | if domain with same id was already added |
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
name | the name of the information |
info | the value of the information |
RuntimeError | there is no timing to add information to, or if adding double information to existing int information |
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
name | the name of the information |
info | the value of the information |
RuntimeError | there is no timing to add information to, or if adding int information to existing double information |
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.
filename | the file to save to |
RuntimeError | on rank 0 if the file cannot be opened for writing. |
void ThunderEgg::Timer::start | ( | const std::string & | name | ) |
Start a new timing.
name | the name of the timing |
void ThunderEgg::Timer::startDomainTiming | ( | int | domain_id, |
const std::string & | name | ||
) |
void ThunderEgg::Timer::startPatchTiming | ( | int | patch_id, |
int | domain_id, | ||
const std::string & | name | ||
) |
void ThunderEgg::Timer::stop | ( | const std::string & | name | ) |
Stop a timing.
name | the name of the timing |
TimerException | if the name does not match the name of the last started timing. |
void ThunderEgg::Timer::stopDomainTiming | ( | int | domain_id, |
const std::string & | name | ||
) |
Stop a Domain associated timing.
domain_id | the id of the Domain |
name | the name of the timing |
RuntimeError | if the domain id and name does not match the name of the last started timing. |
void ThunderEgg::Timer::stopPatchTiming | ( | int | patch_id, |
int | domain_id, | ||
const std::string & | name | ||
) |
Stop a Domain associated timing.
RuntimeError | if the patch id, domain id and name does not match the name of the last started timing. |
|
friend |
ostream operator for Timer, this is collective for all ranks, will only output on rank 0
os | the stream |
timer | the 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.
j | resulting json |
timer | the timer |