8#ifndef PXR_BASE_TRACE_AGGREGATE_NODE_H
9#define PXR_BASE_TRACE_AGGREGATE_NODE_H
13#include "pxr/base/trace/api.h"
14#include "pxr/base/trace/event.h"
15#include "pxr/base/trace/threads.h"
28PXR_NAMESPACE_OPEN_SCOPE
44 using ThisPtr = TraceAggregateNodePtr;
45 using ThisRefPtr = TraceAggregateNodeRefPtr;
54 Id() : _valid(
false) {}
56 bool IsValid()
const {
return _valid; }
61 static ThisRefPtr New() {
62 return This::New(Id(),
TfToken(
"root"), 0, 0);
65 static ThisRefPtr New(
const Id &
id,
69 const int exclusiveCount = 1) {
70 return TfCreateRefPtr(
new This(
id, key, ts, count, exclusiveCount));
73 TRACE_API TraceAggregateNodeRefPtr
74 Append(Id
id,
const TfToken &key, TimeStamp ts,
75 int c = 1,
int xc = 1);
77 TRACE_API
void Append(TraceAggregateNodeRefPtr child);
83 const Id &
GetId() {
return _id;}
97 return recursive ? _recursiveCount : _count;
109 TRACE_API
void AppendInclusiveCounterValue(
int index,
double value);
111 TRACE_API
double GetInclusiveCounterValue(
int index)
const;
113 TRACE_API
void AppendExclusiveCounterValue(
int index,
double value);
115 TRACE_API
double GetExclusiveCounterValue(
int index)
const;
126 const TraceAggregateNodePtrVector GetChildren() {
128 return TraceAggregateNodePtrVector( _children.begin(),_children.end() );
131 const TraceAggregateNodeRefPtrVector &GetChildrenRef() {
135 TRACE_API TraceAggregateNodeRefPtr GetChild(
const TfToken &key);
136 TraceAggregateNodeRefPtr GetChild(
const std::string &key) {
145 _expanded = expanded;
162 TimeStamp scopeOverhead, TimeStamp timerQuantum,
163 uint64_t *numDescendantNodes =
nullptr);
195 int count,
int exclusiveCount) :
196 _id(id), _key(key), _ts(ts), _exclusiveTs(ts),
197 _count(count), _exclusiveCount(exclusiveCount),
198 _recursiveCount(count), _recursiveExclusiveTs(ts), _expanded(false),
199 _isRecursionMarker(false), _isRecursionHead(false),
200 _isRecursionProcessed(false) {}
204 void _MergeRecursive(
const TraceAggregateNodeRefPtr &node);
206 void _SetAsRecursionMarker(TraceAggregateNodePtr parent);
212 TimeStamp _exclusiveTs;
219 TraceAggregateNodePtr _recursionParent;
220 TimeStamp _recursiveExclusiveTs;
222 TraceAggregateNodeRefPtrVector _children;
223 _ChildDictionary _childrenByKey;
228 struct _CounterValue {
229 _CounterValue() : inclusive(0.0), exclusive(0.0) {}
237 _CounterValues _counterValues;
246 _isRecursionMarker:1,
255 _isRecursionProcessed:1;
258PXR_NAMESPACE_CLOSE_SCOPE
This is a space efficient container that mimics the TfHashMap API that uses a vector for storage when...
Enable a concrete base class for use with TfRefPtr.
Token for efficient comparison, assignment, and hashing of known strings.
Enable a concrete base class for use with TfWeakPtr.
A representation of a call tree.
int GetExclusiveCount() const
Returns the exclusive count.
int GetCount(bool recursive=false) const
Returns the call count of this node.
bool IsExpanded()
Returns whether this node is expanded in a gui.
TRACE_API void CalculateInclusiveCounterValues()
Recursively calculates the inclusive counter values from the inclusive and exclusive counts of child ...
TfToken GetKey()
Returns the node's key.
bool IsRecursionHead() const
Returns true if this node is the head of a recursive call tree (i.e.
TRACE_API void AdjustForOverheadAndNoise(TimeStamp scopeOverhead, TimeStamp timerQuantum, uint64_t *numDescendantNodes=nullptr)
Subtract scopeOverhead cost times the number of descendant nodes from the inclusive time of each node...
TRACE_API void MarkRecursiveChildren()
Scans the tree for recursive calls and updates the recursive counts.
TRACE_API TimeStamp GetExclusiveTime(bool recursive=false)
Returns the time spent in this node but not its children.
const Id & GetId()
Returns the node's id.
TimeStamp GetInclusiveTime()
Returns the total time of this node ands its children.
void SetExpanded(bool expanded)
Sets whether or not this node is expanded in a gui.
bool IsRecursionMarker() const
Returns true if this node is simply a marker for a merged recursive subtree; otherwise returns false.
uint64_t TimeStamp
Time in "ticks".
This class represents an identifier for a thread.
Standard pointer typedefs.
#define TF_DECLARE_WEAK_AND_REF_PTRS(type)
Define standard weak, ref, and vector pointer types.
High-resolution, low-cost timing routines.
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...
Pointer storage with deletion detection.