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"
45PXR_NAMESPACE_OPEN_SCOPE
61 using ThisPtr = TraceAggregateNodePtr;
62 using ThisRefPtr = TraceAggregateNodeRefPtr;
71 Id() : _valid(
false) {}
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;
179 TimeStamp scopeOverhead, TimeStamp timerQuantum,
180 uint64_t *numDescendantNodes =
nullptr);
212 int count,
int exclusiveCount) :
213 _id(id), _key(key), _ts(ts), _exclusiveTs(ts),
214 _count(count), _exclusiveCount(exclusiveCount),
215 _recursiveCount(count), _recursiveExclusiveTs(ts), _expanded(false),
216 _isRecursionMarker(false), _isRecursionHead(false),
217 _isRecursionProcessed(false) {}
221 void _MergeRecursive(
const TraceAggregateNodeRefPtr &node);
223 void _SetAsRecursionMarker(TraceAggregateNodePtr parent);
229 TimeStamp _exclusiveTs;
236 TraceAggregateNodePtr _recursionParent;
237 TimeStamp _recursiveExclusiveTs;
239 TraceAggregateNodeRefPtrVector _children;
240 _ChildDictionary _childrenByKey;
245 struct _CounterValue {
246 _CounterValue() : inclusive(0.0), exclusive(0.0) {}
254 _CounterValues _counterValues;
263 _isRecursionMarker:1,
272 _isRecursionProcessed:1;
275PXR_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.