A node in the PerfGraph. More...
#include <PerfNode.h>
Public Member Functions | |
PerfNode (const PerfID id) | |
Create a PerfNode with the given ID. More... | |
PerfID | id () const |
Get the ID of this Node. More... | |
void | setStartTimeAndMemory (const std::chrono::time_point< std::chrono::steady_clock > time, const long int memory) |
Set the current start time. More... | |
const std::chrono::time_point< std::chrono::steady_clock > & | startTime () const |
Get the currnet start time Only makes sense if this node is running. More... | |
const long unsigned int & | startMemory () const |
Get the current start memory Only makes sense if this node is running. More... | |
void | addTimeAndMemory (const std::chrono::time_point< std::chrono::steady_clock > time, const long int memory) |
Add some time into this Node by taking the difference with the time passed in. More... | |
void | incrementNumCalls () |
Increments the number of calls. More... | |
void | addTimeAndMemory (const std::chrono::steady_clock::duration time) |
Add some time into this Node. More... | |
PerfNode * | getChild (const PerfID id) |
Get a child node with the unique id given. More... | |
const std::map< PerfID, std::unique_ptr< PerfNode > > & | children () const |
Get the children. More... | |
std::chrono::steady_clock::duration | selfTime () const |
Get the time this node took. More... | |
Real | selfTimeSec () const |
Get the time this node took in seconds. More... | |
Real | selfTimeAvg () const |
The average time this node took in seconds. More... | |
std::chrono::steady_clock::duration | totalTime () const |
The time this Node plus all of it's children took. More... | |
Real | totalTimeSec () const |
The time this Node plus all of its children took in seconds. More... | |
Real | totalTimeAvg () const |
The average time this Node plus all of its children took in seconds. More... | |
std::chrono::steady_clock::duration | childrenTime () const |
Get the time this nodes children took. More... | |
Real | childrenTimeSec () const |
The time this node's children took in seconds. More... | |
unsigned long int | numCalls () const |
Get the number of times this node was called. More... | |
long int | selfMemory () const |
Get the amount of memory added by this node. More... | |
long int | childrenMemory () const |
Get the amount of memory added by this node. More... | |
long int | totalMemory () const |
Get the amount of memory added by this node. More... | |
Private Attributes | |
const PerfID | _id |
The unique ID for the section this Node corresponds to. More... | |
std::chrono::time_point< std::chrono::steady_clock > | _start_time |
The current start_time for this node (if it's on the stack) More... | |
std::chrono::steady_clock::duration | _total_time |
The total elapsed time for this node. More... | |
long unsigned int | _start_memory |
The starting memory for this node. More... | |
long unsigned int | _num_calls |
Number of times this node has been called. More... | |
long unsigned int | _total_memory |
The total memory added while this node is active. More... | |
std::map< PerfID, std::unique_ptr< PerfNode > > | _children |
Timers that are directly underneath this node. More... | |
Friends | |
void | dataStore (std::ostream &, const std::unique_ptr< PerfNode > &, void *) |
void | dataLoad (std::istream &, const std::unique_ptr< PerfNode > &, void *) |
A node in the PerfGraph.
Stores the timing for a particular section of code.
The design here is that _children are automatically added and kept track of within the Node - and only raw pointers are handed back out.
Definition at line 24 of file PerfNode.h.
|
inline |
Create a PerfNode with the given ID.
Definition at line 30 of file PerfNode.h.
|
inline |
Add some time into this Node by taking the difference with the time passed in.
Definition at line 65 of file PerfNode.h.
|
inline |
Add some time into this Node.
Definition at line 80 of file PerfNode.h.
Get the children.
Definition at line 106 of file PerfNode.h.
Referenced by PerfGraph::recursivelyUpdate(), to_json(), and PerfGraph::treeRecurseInternal().
long int PerfNode::childrenMemory | ( | ) | const |
Get the amount of memory added by this node.
Definition at line 47 of file PerfNode.C.
Referenced by PerfGraph::recursivelyUpdate(), and selfMemory().
std::chrono::steady_clock::duration PerfNode::childrenTime | ( | ) | const |
Get the time this nodes children took.
Definition at line 30 of file PerfNode.C.
Referenced by childrenTimeSec(), and selfTime().
|
inline |
The time this node's children took in seconds.
Definition at line 141 of file PerfNode.h.
Referenced by PerfGraph::recursivelyUpdate().
Get a child node with the unique id given.
Note: this will automatically create the Node internally if it needs to.
Implemented in header to allow for more optimization
id | The unique ID of the child node |
Definition at line 92 of file PerfNode.h.
|
inline |
Get the ID of this Node.
Definition at line 35 of file PerfNode.h.
Referenced by getChild(), PerfGraph::recursivelyUpdate(), to_json(), and PerfGraph::treeRecurseInternal().
|
inline |
Increments the number of calls.
Definition at line 75 of file PerfNode.h.
Referenced by PerfGraph::push().
|
inline |
Get the number of times this node was called.
Definition at line 146 of file PerfNode.h.
Referenced by PerfGraph::recursivelyUpdate(), selfTimeAvg(), to_json(), totalTimeAvg(), and PerfGraph::treeTable().
long int PerfNode::selfMemory | ( | ) | const |
Get the amount of memory added by this node.
Definition at line 41 of file PerfNode.C.
Referenced by PerfGraph::recursivelyUpdate(), to_json(), and PerfGraph::treeTable().
std::chrono::steady_clock::duration PerfNode::selfTime | ( | ) | const |
Get the time this node took.
Definition at line 16 of file PerfNode.C.
Referenced by selfTimeSec().
|
inline |
The average time this node took in seconds.
Definition at line 119 of file PerfNode.h.
Referenced by PerfGraph::treeTable().
|
inline |
Get the time this node took in seconds.
Definition at line 115 of file PerfNode.h.
Referenced by PerfGraph::recursivelyUpdate(), selfTimeAvg(), to_json(), and PerfGraph::treeTable().
|
inline |
Set the current start time.
Definition at line 40 of file PerfNode.h.
Referenced by PerfGraph::push().
|
inline |
Get the current start memory Only makes sense if this node is running.
Definition at line 60 of file PerfNode.h.
|
inline |
Get the currnet start time Only makes sense if this node is running.
Definition at line 51 of file PerfNode.h.
|
inline |
Get the amount of memory added by this node.
Definition at line 161 of file PerfNode.h.
Referenced by PerfGraph::recursivelyUpdate(), and PerfGraph::treeTable().
std::chrono::steady_clock::duration PerfNode::totalTime | ( | ) | const |
The time this Node plus all of it's children took.
Definition at line 22 of file PerfNode.C.
Referenced by totalTimeSec(), and PerfGraph::treeRecurseInternal().
|
inline |
The average time this Node plus all of its children took in seconds.
Definition at line 132 of file PerfNode.h.
Referenced by PerfGraph::treeTable().
|
inline |
The time this Node plus all of its children took in seconds.
Definition at line 128 of file PerfNode.h.
Referenced by PerfGraph::recursivelyUpdate(), totalTimeAvg(), and PerfGraph::treeTable().
|
friend |
Definition at line 79 of file PerfNode.C.
|
friend |
Definition at line 58 of file PerfNode.C.
Timers that are directly underneath this node.
Definition at line 183 of file PerfNode.h.
Referenced by children(), childrenMemory(), childrenTime(), and getChild().
|
private |
The unique ID for the section this Node corresponds to.
Definition at line 165 of file PerfNode.h.
Referenced by id().
|
private |
Number of times this node has been called.
Definition at line 177 of file PerfNode.h.
Referenced by incrementNumCalls(), and numCalls().
|
private |
The starting memory for this node.
Definition at line 174 of file PerfNode.h.
Referenced by addTimeAndMemory(), setStartTimeAndMemory(), and startMemory().
|
private |
The current start_time for this node (if it's on the stack)
Definition at line 168 of file PerfNode.h.
Referenced by addTimeAndMemory(), setStartTimeAndMemory(), and startTime().
|
private |
The total memory added while this node is active.
Definition at line 180 of file PerfNode.h.
Referenced by addTimeAndMemory(), selfMemory(), and totalMemory().
|
private |
The total elapsed time for this node.
Definition at line 171 of file PerfNode.h.
Referenced by addTimeAndMemory(), selfTime(), and totalTime().