Loading...
Searching...
No Matches
aggregateTree.h
1//
2// Copyright 2018 Pixar
3//
4// Licensed under the Apache License, Version 2.0 (the "Apache License")
5// with the following modification; you may not use this file except in
6// compliance with the Apache License and the following modification to it:
7// Section 6. Trademarks. is deleted and replaced with:
8//
9// 6. Trademarks. This License does not grant permission to use the trade
10// names, trademarks, service marks, or product names of the Licensor
11// and its affiliates, except as required to comply with Section 4(c) of
12// the License and to reproduce the content of the NOTICE file.
13//
14// You may obtain a copy of the Apache License at
15//
16// http://www.apache.org/licenses/LICENSE-2.0
17//
18// Unless required by applicable law or agreed to in writing, software
19// distributed under the Apache License with the above modification is
20// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21// KIND, either express or implied. See the Apache License for the specific
22// language governing permissions and limitations under the Apache License.
23//
24
25#ifndef PXR_BASE_TRACE_AGGREGATE_TREE_H
26#define PXR_BASE_TRACE_AGGREGATE_TREE_H
27
28#include "pxr/pxr.h"
29
30#include "pxr/base/trace/api.h"
31#include "pxr/base/trace/aggregateNode.h"
32
33PXR_NAMESPACE_OPEN_SCOPE
34
35class TraceCollection;
36
39
47
48class TraceAggregateTree : public TfRefBase, public TfWeakBase {
49public:
51 using ThisPtr = TraceAggregateTreePtr;
52 using ThisRefPtr = TraceAggregateTreeRefPtr;
53
54 using TimeStamp = TraceEvent::TimeStamp;
55 using EventTimes = std::map<TfToken, TimeStamp>;
56 using CounterMap = TfHashMap<TfToken, double, TfToken::HashFunctor>;
57
59 static ThisRefPtr New() {
60 return TfCreateRefPtr(new This());
61 }
62
64 TraceAggregateNodePtr GetRoot() { return _root; }
65
67 const EventTimes& GetEventTimes() const { return _eventTimes; }
68
72 const CounterMap& GetCounters() const { return _counters; }
73
76 TRACE_API int GetCounterIndex(const TfToken &key) const;
77
82 TRACE_API bool AddCounter(const TfToken &key, int index, double totalValue);
83
85 TRACE_API void Clear();
86
89 TRACE_API void Append(
90 const TraceEventTreeRefPtr& eventTree,
91 const TraceCollection& collection);
92
93private:
94 TRACE_API TraceAggregateTree();
95
96 using _CounterIndexMap =TfHashMap<TfToken, int, TfToken::HashFunctor>;
97
98 TraceAggregateNodeRefPtr _root;
99 EventTimes _eventTimes;
100 CounterMap _counters;
101 _CounterIndexMap _counterIndexMap;
102 int _counterIndex;
103
104 friend class Trace_AggregateTreeBuilder;
105};
106
107PXR_NAMESPACE_CLOSE_SCOPE
108
109#endif // PXR_BASE_TRACE_AGGREGATE_TREE_H
Enable a concrete base class for use with TfRefPtr.
Definition: refBase.h:73
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:88
Enable a concrete base class for use with TfWeakPtr.
Definition: weakBase.h:141
A representation of a call tree.
Definition: aggregateTree.h:48
const CounterMap & GetCounters() const
Returns a map of counters (counter keys), associated with their total accumulated value.
Definition: aggregateTree.h:72
const EventTimes & GetEventTimes() const
Returns a map of event keys to total inclusive time.
Definition: aggregateTree.h:67
static ThisRefPtr New()
Create an empty tree.
Definition: aggregateTree.h:59
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:64
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:49
uint64_t TimeStamp
Time in "ticks".
Definition: event.h:50
This class contains a timeline call tree and a map of counters to their values over time.
Definition: eventTree.h:58
#define TF_DECLARE_WEAK_AND_REF_PTRS(type)
Define standard weak, ref, and vector pointer types.
Definition: declarePtrs.h:89