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;
49 static ThisRefPtr New() {
50 return This::New(
TfToken(
"root"), 0, 0);
53 static ThisRefPtr New(
const TfToken &key,
56 const int exclusiveCount = 1) {
57 return TfCreateRefPtr(
new This(key, ts, count, exclusiveCount));
60 TRACE_API TraceAggregateNodeRefPtr
61 Append(
const TfToken &key, TimeStamp ts,
62 int c = 1,
int xc = 1);
64 TRACE_API
void Append(TraceAggregateNodeRefPtr child);
81 return recursive ? _recursiveCount : _count;
93 TRACE_API
void AppendInclusiveCounterValue(
int index,
double value);
95 TRACE_API
double GetInclusiveCounterValue(
int index)
const;
97 TRACE_API
void AppendExclusiveCounterValue(
int index,
double value);
99 TRACE_API
double GetExclusiveCounterValue(
int index)
const;
110 const TraceAggregateNodePtrVector GetChildren() {
112 return TraceAggregateNodePtrVector( _children.begin(),_children.end() );
115 const TraceAggregateNodeRefPtrVector &GetChildrenRef() {
119 TRACE_API TraceAggregateNodeRefPtr GetChild(
const TfToken &key);
120 TraceAggregateNodeRefPtr GetChild(
const std::string &key) {
129 _expanded = expanded;
146 TimeStamp scopeOverhead, TimeStamp timerQuantum,
147 uint64_t *numDescendantNodes =
nullptr);
179 int count,
int exclusiveCount) :
180 _key(key), _ts(ts), _exclusiveTs(ts),
181 _count(count), _exclusiveCount(exclusiveCount),
182 _recursiveCount(count), _recursiveExclusiveTs(ts), _expanded(false),
183 _isRecursionMarker(false), _isRecursionHead(false),
184 _isRecursionProcessed(false) {}
188 void _MergeRecursive(
const TraceAggregateNodeRefPtr &node);
190 void _SetAsRecursionMarker(TraceAggregateNodePtr parent);
194 TimeStamp _exclusiveTs;
201 TraceAggregateNodePtr _recursionParent;
202 TimeStamp _recursiveExclusiveTs;
204 TraceAggregateNodeRefPtrVector _children;
205 _ChildDictionary _childrenByKey;
210 struct _CounterValue {
211 _CounterValue() : inclusive(0.0), exclusive(0.0) {}
219 _CounterValues _counterValues;
228 _isRecursionMarker:1,
237 _isRecursionProcessed:1;
240PXR_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 ...
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.
TimeStamp GetInclusiveTime()
Returns the total time of this node ands its children.
const TfToken & GetKey()
Returns the node's key.
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".
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.