25 #ifndef PXR_BASE_TRACE_AGGREGATE_NODE_H
26 #define PXR_BASE_TRACE_AGGREGATE_NODE_H
30 #include "pxr/base/trace/api.h"
31 #include "pxr/base/trace/event.h"
32 #include "pxr/base/trace/threads.h"
45 PXR_NAMESPACE_OPEN_SCOPE
61 using ThisPtr = TraceAggregateNodePtr;
62 using ThisRefPtr = TraceAggregateNodeRefPtr;
71 Id() : _valid(
false) {}
72 Id(
const TraceThreadId&) : _valid(
true) {}
73 bool IsValid()
const {
return _valid; }
78 static ThisRefPtr New() {
79 return This::New(Id(),
TfToken(
"root"), 0, 0);
82 static ThisRefPtr New(
const Id &
id,
86 const int exclusiveCount = 1) {
87 return TfCreateRefPtr(
new This(
id, key, ts, count, exclusiveCount));
90 TRACE_API TraceAggregateNodeRefPtr
91 Append(Id
id,
const TfToken &key, TimeStamp ts,
92 int c = 1,
int xc = 1);
94 TRACE_API
void Append(TraceAggregateNodeRefPtr child);
114 return recursive ? _recursiveCount : _count;
126 TRACE_API
void AppendInclusiveCounterValue(
int index,
double value);
128 TRACE_API
double GetInclusiveCounterValue(
int index)
const;
130 TRACE_API
void AppendExclusiveCounterValue(
int index,
double value);
132 TRACE_API
double GetExclusiveCounterValue(
int index)
const;
143 const TraceAggregateNodePtrVector GetChildren() {
145 return TraceAggregateNodePtrVector( _children.begin(),_children.end() );
148 const TraceAggregateNodeRefPtrVector &GetChildrenRef() {
152 TRACE_API TraceAggregateNodeRefPtr GetChild(
const TfToken &key);
153 TraceAggregateNodeRefPtr GetChild(
const std::string &key) {
162 _expanded = expanded;
200 int count,
int exclusiveCount) :
201 _id(id), _key(key), _ts(ts), _exclusiveTs(ts),
202 _count(count), _exclusiveCount(exclusiveCount),
203 _recursiveCount(count), _recursiveExclusiveTs(ts), _expanded(false),
204 _isRecursionMarker(false), _isRecursionHead(false),
205 _isRecursionProcessed(false) {}
209 void _MergeRecursive(
const TraceAggregateNodeRefPtr &node);
211 void _SetAsRecursionMarker(TraceAggregateNodePtr parent);
217 TimeStamp _exclusiveTs;
224 TraceAggregateNodePtr _recursionParent;
225 TimeStamp _recursiveExclusiveTs;
227 TraceAggregateNodeRefPtrVector _children;
228 _ChildDictionary _childrenByKey;
233 struct _CounterValue {
234 _CounterValue() : inclusive(0.0), exclusive(0.0) {}
242 _CounterValues _counterValues;
251 _isRecursionMarker:1,
260 _isRecursionProcessed:1;
263 PXR_NAMESPACE_CLOSE_SCOPE
265 #endif // PXR_BASE_TRACE_AGGREGATE_NODE_H
Standard pointer typedefs.
TRACE_API TimeStamp GetExclusiveTime(bool recursive=false)
Returns the time spent in this node but not its children.
uint64_t TimeStamp
Time in "ticks".
bool IsRecursionHead() const
Returns true if this node is the head of a recursive call tree (i.e.
Pointer storage with deletion detection.
#define TF_DECLARE_WEAK_AND_REF_PTRS(type)
Define standard weak, ref, and vector pointer types.
const Id & GetId()
Returns the node's id.
Enable a concrete base class for use with TfRefPtr.
bool IsExpanded()
Returns whether this node is expanded in a gui.
Token for efficient comparison, assignment, and hashing of known strings.
TRACE_API void MarkRecursiveChildren()
Scans the tree for recursive calls and updates the recursive counts.
TfToken GetKey()
Returns the node's key.
int GetCount(bool recursive=false) const
Returns the call count of this node.
A representation of a call tree.
bool IsRecursionMarker() const
Returns true if this node is simply a marker for a merged recursive subtree; otherwise returns false...
TRACE_API void CalculateInclusiveCounterValues()
Recursively calculates the inclusive counter values from the inclusive and exclusive counts of child ...
int GetExclusiveCount() const
Returns the exclusive count.
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.
Enable a concrete base class for use with TfWeakPtr.
High-resolution, low-cost timing routines.
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...