www.mooseframework.org
Public Member Functions | Protected Attributes | List of all members
PerfNode Class Reference

#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 setStartTime (const std::chrono::time_point< std::chrono::steady_clock > time)
 Set the current start time. More...
 
void addTime (const std::chrono::time_point< std::chrono::steady_clock > time)
 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 addTime (const std::chrono::steady_clock::duration time)
 Add some time into this Node. More...
 
PerfNodegetChild (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...
 
std::chrono::steady_clock::duration totalTime () const
 The time this Node plus all of it's children took. More...
 
std::chrono::steady_clock::duration childrenTime () const
 Get the time this nodes children took. More...
 
unsigned long int numCalls ()
 Get the number of times this node was called. More...
 

Protected Attributes

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 _num_calls
 Number of times this node has been called. More...
 
std::map< PerfID, std::unique_ptr< PerfNode > > _children
 Timers that are directly underneath this node. More...
 

Detailed Description

Definition at line 24 of file PerfNode.h.

Constructor & Destructor Documentation

◆ PerfNode()

PerfNode::PerfNode ( const PerfID  id)
inline

Create a PerfNode with the given ID.

Definition at line 30 of file PerfNode.h.

Referenced by getChild().

30 : _id(id), _total_time(0), _num_calls(0) {}
long unsigned int _num_calls
Number of times this node has been called.
Definition: PerfNode.h:120
std::chrono::steady_clock::duration _total_time
The total elapsed time for this node.
Definition: PerfNode.h:117
PerfID _id
The unique ID for the section this Node corresponds to.
Definition: PerfNode.h:111

Member Function Documentation

◆ addTime() [1/2]

void PerfNode::addTime ( const std::chrono::time_point< std::chrono::steady_clock >  time)
inline

Add some time into this Node by taking the difference with the time passed in.

Definition at line 48 of file PerfNode.h.

49  {
50  _total_time += time - _start_time;
51  }
std::chrono::steady_clock::duration _total_time
The total elapsed time for this node.
Definition: PerfNode.h:117
std::chrono::time_point< std::chrono::steady_clock > _start_time
The current start_time for this node (if it&#39;s on the stack)
Definition: PerfNode.h:114

◆ addTime() [2/2]

void PerfNode::addTime ( const std::chrono::steady_clock::duration  time)
inline

Add some time into this Node.

Definition at line 61 of file PerfNode.h.

61 { _total_time += time; }
std::chrono::steady_clock::duration _total_time
The total elapsed time for this node.
Definition: PerfNode.h:117

◆ children()

const std::map<PerfID, std::unique_ptr<PerfNode> >& PerfNode::children ( ) const
inline

Get the children.

Definition at line 87 of file PerfNode.h.

Referenced by PerfGraph::recursivelyFillTime(), PerfGraph::recursivelyPrintGraph(), and PerfGraph::recursivelyPrintHeaviestGraph().

87 { return _children; }
std::map< PerfID, std::unique_ptr< PerfNode > > _children
Timers that are directly underneath this node.
Definition: PerfNode.h:123

◆ childrenTime()

std::chrono::steady_clock::duration PerfNode::childrenTime ( ) const

Get the time this nodes children took.

Definition at line 27 of file PerfNode.C.

Referenced by PerfGraph::recursivelyFillTime(), PerfGraph::recursivelyPrintGraph(), PerfGraph::recursivelyPrintHeaviestGraph(), and selfTime().

28 {
29  std::chrono::steady_clock::duration children_time(0);
30 
31  for (auto & child_it : _children)
32  children_time += child_it.second->totalTime();
33 
34  return children_time;
35 }
std::map< PerfID, std::unique_ptr< PerfNode > > _children
Timers that are directly underneath this node.
Definition: PerfNode.h:123

◆ getChild()

PerfNode* PerfNode::getChild ( const PerfID  id)
inline

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

Parameters
idThe unique ID of the child node
Returns
The pointer to the child node

Definition at line 73 of file PerfNode.h.

74  {
75  // RHS insertion on purpose
76  auto & child_node = _children[id];
77 
78  if (!child_node)
79  child_node.reset(new PerfNode(id));
80 
81  return child_node.get();
82  }
PerfID id() const
Get the ID of this Node.
Definition: PerfNode.h:35
std::map< PerfID, std::unique_ptr< PerfNode > > _children
Timers that are directly underneath this node.
Definition: PerfNode.h:123
PerfNode(const PerfID id)
Create a PerfNode with the given ID.
Definition: PerfNode.h:30

◆ id()

PerfID PerfNode::id ( ) const
inline

Get the ID of this Node.

Definition at line 35 of file PerfNode.h.

Referenced by getChild(), PerfGraph::recursivelyFillTime(), PerfGraph::recursivelyPrintGraph(), and PerfGraph::recursivelyPrintHeaviestGraph().

35 { return _id; }
PerfID _id
The unique ID for the section this Node corresponds to.
Definition: PerfNode.h:111

◆ incrementNumCalls()

void PerfNode::incrementNumCalls ( )
inline

Increments the number of calls.

Definition at line 56 of file PerfNode.h.

56 { _num_calls++; }
long unsigned int _num_calls
Number of times this node has been called.
Definition: PerfNode.h:120

◆ numCalls()

unsigned long int PerfNode::numCalls ( )
inline

Get the number of times this node was called.

Definition at line 107 of file PerfNode.h.

Referenced by PerfGraph::recursivelyFillTime(), PerfGraph::recursivelyPrintGraph(), and PerfGraph::recursivelyPrintHeaviestGraph().

107 { return _num_calls; }
long unsigned int _num_calls
Number of times this node has been called.
Definition: PerfNode.h:120

◆ selfTime()

std::chrono::steady_clock::duration PerfNode::selfTime ( ) const

Get the time this node took.

Definition at line 13 of file PerfNode.C.

Referenced by PerfGraph::recursivelyFillTime(), PerfGraph::recursivelyPrintGraph(), and PerfGraph::recursivelyPrintHeaviestGraph().

14 {
15  return _total_time - childrenTime();
16 }
std::chrono::steady_clock::duration childrenTime() const
Get the time this nodes children took.
Definition: PerfNode.C:27
std::chrono::steady_clock::duration _total_time
The total elapsed time for this node.
Definition: PerfNode.h:117

◆ setStartTime()

void PerfNode::setStartTime ( const std::chrono::time_point< std::chrono::steady_clock >  time)
inline

Set the current start time.

Definition at line 40 of file PerfNode.h.

41  {
42  _start_time = time;
43  }
std::chrono::time_point< std::chrono::steady_clock > _start_time
The current start_time for this node (if it&#39;s on the stack)
Definition: PerfNode.h:114

◆ totalTime()

std::chrono::steady_clock::duration PerfNode::totalTime ( ) const

The time this Node plus all of it's children took.

Definition at line 19 of file PerfNode.C.

Referenced by PerfGraph::recursivelyFillTime(), PerfGraph::recursivelyPrintGraph(), and PerfGraph::recursivelyPrintHeaviestGraph().

20 {
21  // Note that all of the children's time is already
22  // accounte for in the total time
23  return _total_time;
24 }
std::chrono::steady_clock::duration _total_time
The total elapsed time for this node.
Definition: PerfNode.h:117

Member Data Documentation

◆ _children

std::map<PerfID, std::unique_ptr<PerfNode> > PerfNode::_children
protected

Timers that are directly underneath this node.

Definition at line 123 of file PerfNode.h.

Referenced by children(), childrenTime(), and getChild().

◆ _id

PerfID PerfNode::_id
protected

The unique ID for the section this Node corresponds to.

Definition at line 111 of file PerfNode.h.

Referenced by id().

◆ _num_calls

long unsigned int PerfNode::_num_calls
protected

Number of times this node has been called.

Definition at line 120 of file PerfNode.h.

Referenced by incrementNumCalls(), and numCalls().

◆ _start_time

std::chrono::time_point<std::chrono::steady_clock> PerfNode::_start_time
protected

The current start_time for this node (if it's on the stack)

Definition at line 114 of file PerfNode.h.

Referenced by addTime(), and setStartTime().

◆ _total_time

std::chrono::steady_clock::duration PerfNode::_total_time
protected

The total elapsed time for this node.

Definition at line 117 of file PerfNode.h.

Referenced by addTime(), selfTime(), and totalTime().


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