Loading...
Searching...
No Matches
terra::util::TimerTree Class Reference

Singleton tree managing all timer nodes per MPI rank. More...

#include <timer.hpp>

Public Member Functions

void clear ()
 
void enter_scope (const std::string &name)
 Enter a new timing scope.
 
void exit_scope (double elapsed)
 Exit the current timing scope and record elapsed time.
 
std::string json ()
 Per-rank json tree.
 
std::string json_aggregate ()
 MPI-reduced / aggregate json.
 
void aggregate_mpi ()
 Aggregate timings across all MPI ranks.
 

Static Public Member Functions

static TimerTreeinstance ()
 Access the singleton instance.
 

Detailed Description

Singleton tree managing all timer nodes per MPI rank.

Note
Use Timer class for the actually starting and stopping timers. Internally Timer objects will access a TimerTree singleton. So you can easily add timer calls without changing the API of your code.

Can be exported via json.

Example:

auto tt = TimerTree::instance();
tt.aggregate_mpi();
std::cout << tt.json() << std::endl;
std::cout << tt.json_aggregate() << std::endl;
tt.clear();
static TimerTree & instance()
Access the singleton instance.
Definition timer.hpp:161

Example output for json(). Note that the root node will always be there carrying no timings.

{
"name": "root",
"total_time": 0,
"count": 0,
"children": [
{
"name": "laplace_apply",
"total_time": 0.356301,
"count": 28,
"children": [
{
"name": "laplace_comm",
"total_time": 0.02748,
"count": 28,
"children": [
]
},
{
"name": "laplace_kernel",
"total_time": 0.327421,
"count": 28,
"children": [
]
}
]
}
]
}

Member Function Documentation

◆ aggregate_mpi()

void terra::util::TimerTree::aggregate_mpi ( )
inline

Aggregate timings across all MPI ranks.

Must be called collectively.

◆ clear()

void terra::util::TimerTree::clear ( )
inline

◆ enter_scope()

void terra::util::TimerTree::enter_scope ( const std::string &  name)
inline

Enter a new timing scope.

◆ exit_scope()

void terra::util::TimerTree::exit_scope ( double  elapsed)
inline

Exit the current timing scope and record elapsed time.

◆ instance()

static TimerTree & terra::util::TimerTree::instance ( )
inlinestatic

Access the singleton instance.

◆ json()

std::string terra::util::TimerTree::json ( )
inline

Per-rank json tree.

Returns a definitely non-reduced timer tree in json format. This means that this returns the process-local timings depending on the process that calls this method.

◆ json_aggregate()

std::string terra::util::TimerTree::json_aggregate ( )
inline

MPI-reduced / aggregate json.

Returns the timings after reduction over all processes. You need to call aggregate_mpi() before this for reasonable results.

This method does not need to be called collectively.


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