25 #ifndef PXR_BASE_TRACE_EVENT_TREE_H 26 #define PXR_BASE_TRACE_EVENT_TREE_H 30 #include "pxr/base/trace/api.h" 31 #include "pxr/base/trace/event.h" 32 #include "pxr/base/trace/eventNode.h" 33 #include "pxr/base/trace/threads.h" 43 #include <unordered_map> 45 PXR_NAMESPACE_OPEN_SCOPE
60 using CounterValues = std::vector<std::pair<TraceEvent::TimeStamp, double>>;
61 using CounterValuesMap =
62 std::unordered_map<TfToken, CounterValues, TfToken::HashFunctor>;
64 std::unordered_map<TfToken, double, TfToken::HashFunctor>;
66 using MarkerValues = std::vector<std::pair<TraceEvent::TimeStamp, TraceThreadId>>;
67 using MarkerValuesMap =
68 std::unordered_map<TfToken, MarkerValues, TfToken::HashFunctor>;
72 TRACE_API
static TraceEventTreeRefPtr
New(
74 const CounterMap* initialCounterValues =
nullptr);
76 static TraceEventTreeRefPtr New() {
77 return TfCreateRefPtr(
81 static TraceEventTreeRefPtr New(
82 TraceEventNodeRefPtr root,
83 CounterValuesMap counters,
84 MarkerValuesMap markers) {
85 return TfCreateRefPtr(
86 new TraceEventTree(root, std::move(counters), std::move(markers)));
90 const TraceEventNodeRefPtr&
GetRoot()
const {
return _root; }
93 const CounterValuesMap&
GetCounters()
const {
return _counters; }
96 const MarkerValuesMap&
GetMarkers()
const {
return _markers; }
104 TRACE_API
void WriteChromeTraceObject(
108 TRACE_API
void Merge(
const TraceEventTreeRefPtr& tree);
118 CounterValuesMap counters,
119 MarkerValuesMap markers)
121 , _counters(std::move(counters))
122 , _markers(std::move(markers)) {}
125 TraceEventNodeRefPtr _root;
127 CounterValuesMap _counters;
129 MarkerValuesMap _markers;
132 PXR_NAMESPACE_CLOSE_SCOPE
134 #endif // PXR_BASE_TRACE_EVENT_TREE_H Standard pointer typedefs.
This class contains a timeline call tree and a map of counters to their values over time.
TRACE_API TraceEventTreeRefPtr Add(const TraceCollection &collection)
Adds the data from collection to this tree.
Pointer storage with deletion detection.
#define TF_DECLARE_WEAK_AND_REF_PTRS(type)
Define standard weak, ref, and vector pointer types.
static TRACE_API TraceEventTreeRefPtr New(const TraceCollection &collection, const CounterMap *initialCounterValues=nullptr)
Creates a new TraceEventTree instance from the data in collection and initialCounterValues.
TRACE_API void Merge(const TraceEventTreeRefPtr &tree)
Adds the contexts of tree to this tree.
Enable a concrete base class for use with TfRefPtr.
const CounterValuesMap & GetCounters() const
Returns the map of counter values.
static TraceEventNodeRefPtr New()
Creates a new root node.
This class owns lists of TraceEvent instances per thread, and allows read access to them.
const TraceEventNodeRefPtr & GetRoot() const
Returns the root node of the tree.
const MarkerValuesMap & GetMarkers() const
Returns the map of markers values.
Enable a concrete base class for use with TfWeakPtr.
This class provides an interface to writing json values directly to a stream.
CounterMap GetFinalCounterValues() const
Return the final value of the counters in the report.
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...
std::function< void(JsWriter &)> ExtraFieldFn
Writes a JSON object representing the data in the call tree that conforms to the Chrome Trace format.