Loading...
Searching...
No Matches
aggregateTree.h
1//
2// Copyright 2018 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7
8#ifndef PXR_BASE_TRACE_AGGREGATE_TREE_H
9#define PXR_BASE_TRACE_AGGREGATE_TREE_H
10
11#include "pxr/pxr.h"
12
13#include "pxr/base/trace/api.h"
14#include "pxr/base/trace/aggregateNode.h"
15
16PXR_NAMESPACE_OPEN_SCOPE
17
18class TraceCollection;
19
22
30
31class TraceAggregateTree : public TfRefBase, public TfWeakBase {
32public:
34 using ThisPtr = TraceAggregateTreePtr;
35 using ThisRefPtr = TraceAggregateTreeRefPtr;
36
37 using TimeStamp = TraceEvent::TimeStamp;
38 using EventTimes = std::map<TfToken, TimeStamp>;
39 using CounterMap = TfHashMap<TfToken, double, TfToken::HashFunctor>;
40
42 static ThisRefPtr New() {
43 return TfCreateRefPtr(new This());
44 }
45
47 TraceAggregateNodePtr GetRoot() { return _root; }
48
50 const EventTimes& GetEventTimes() const { return _eventTimes; }
51
55 const CounterMap& GetCounters() const { return _counters; }
56
59 TRACE_API int GetCounterIndex(const TfToken &key) const;
60
65 TRACE_API bool AddCounter(const TfToken &key, int index, double totalValue);
66
68 TRACE_API void Clear();
69
72 TRACE_API void Append(
73 const TraceEventTreeRefPtr& eventTree,
74 const TraceCollection& collection);
75
76private:
77 TRACE_API TraceAggregateTree();
78
79 using _CounterIndexMap =TfHashMap<TfToken, int, TfToken::HashFunctor>;
80
81 TraceAggregateNodeRefPtr _root;
82 EventTimes _eventTimes;
83 CounterMap _counters;
84 _CounterIndexMap _counterIndexMap;
85 int _counterIndex;
86
87 friend class Trace_AggregateTreeBuilder;
88};
89
90PXR_NAMESPACE_CLOSE_SCOPE
91
92#endif // PXR_BASE_TRACE_AGGREGATE_TREE_H
Enable a concrete base class for use with TfRefPtr.
Definition: refBase.h:56
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71
Enable a concrete base class for use with TfWeakPtr.
Definition: weakBase.h:124
A representation of a call tree.
Definition: aggregateTree.h:31
const CounterMap & GetCounters() const
Returns a map of counters (counter keys), associated with their total accumulated value.
Definition: aggregateTree.h:55
const EventTimes & GetEventTimes() const
Returns a map of event keys to total inclusive time.
Definition: aggregateTree.h:50
static ThisRefPtr New()
Create an empty tree.
Definition: aggregateTree.h:42
TRACE_API void Clear()
Removes all data and nodes from the tree.
TRACE_API void Append(const TraceEventTreeRefPtr &eventTree, const TraceCollection &collection)
Creates new nodes and counter data from data in eventTree and collection.
TRACE_API bool AddCounter(const TfToken &key, int index, double totalValue)
Add a counter to the tree.
TraceAggregateNodePtr GetRoot()
Returns the root node of the tree.
Definition: aggregateTree.h:47
TRACE_API int GetCounterIndex(const TfToken &key) const
Returns the numeric index associated with a counter key.
This class owns lists of TraceEvent instances per thread, and allows read access to them.
Definition: collection.h:32
uint64_t TimeStamp
Time in "ticks".
Definition: event.h:33
This class contains a timeline call tree and a map of counters to their values over time.
Definition: eventTree.h:41
#define TF_DECLARE_WEAK_AND_REF_PTRS(type)
Define standard weak, ref, and vector pointer types.
Definition: declarePtrs.h:72