8#ifndef PXR_BASE_TRACE_EVENT_TREE_H
9#define PXR_BASE_TRACE_EVENT_TREE_H
13#include "pxr/base/trace/api.h"
14#include "pxr/base/trace/event.h"
15#include "pxr/base/trace/eventNode.h"
16#include "pxr/base/trace/threads.h"
26#include <unordered_map>
28PXR_NAMESPACE_OPEN_SCOPE
43 using CounterValues = std::vector<std::pair<TraceEvent::TimeStamp, double>>;
44 using CounterValuesMap =
45 std::unordered_map<TfToken, CounterValues, TfToken::HashFunctor>;
47 std::unordered_map<TfToken, double, TfToken::HashFunctor>;
49 using MarkerValues = std::vector<std::pair<TraceEvent::TimeStamp, TraceThreadId>>;
50 using MarkerValuesMap =
51 std::unordered_map<TfToken, MarkerValues, TfToken::HashFunctor>;
55 TRACE_API
static TraceEventTreeRefPtr
New(
57 const CounterMap* initialCounterValues =
nullptr);
59 static TraceEventTreeRefPtr
New() {
60 return TfCreateRefPtr(
64 static TraceEventTreeRefPtr New(
65 TraceEventNodeRefPtr root,
66 CounterValuesMap counters,
67 MarkerValuesMap markers) {
68 return TfCreateRefPtr(
69 new TraceEventTree(root, std::move(counters), std::move(markers)));
73 const TraceEventNodeRefPtr&
GetRoot()
const {
return _root; }
76 const CounterValuesMap&
GetCounters()
const {
return _counters; }
79 const MarkerValuesMap&
GetMarkers()
const {
return _markers; }
87 TRACE_API
void WriteChromeTraceObject(
91 TRACE_API
void Merge(
const TraceEventTreeRefPtr& tree);
101 CounterValuesMap counters,
102 MarkerValuesMap markers)
104 , _counters(
std::move(counters))
105 , _markers(
std::move(markers)) {}
108 TraceEventNodeRefPtr _root;
110 CounterValuesMap _counters;
112 MarkerValuesMap _markers;
115PXR_NAMESPACE_CLOSE_SCOPE
This class provides an interface to writing json values directly to a stream.
Enable a concrete base class for use with TfRefPtr.
Enable a concrete base class for use with TfWeakPtr.
This class owns lists of TraceEvent instances per thread, and allows read access to them.
static TraceEventNodeRefPtr New()
Creates a new root node.
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.
static TRACE_API TraceEventTreeRefPtr New(const TraceCollection &collection, const CounterMap *initialCounterValues=nullptr)
Creates a new TraceEventTree instance from the data in collection and initialCounterValues.
CounterMap GetFinalCounterValues() const
Return the final value of the counters in the report.
TRACE_API void Merge(const TraceEventTreeRefPtr &tree)
Adds the contexts of tree to this tree.
const TraceEventNodeRefPtr & GetRoot() const
Returns the root node of the tree.
const MarkerValuesMap & GetMarkers() const
Returns the map of markers values.
std::function< void(JsWriter &)> ExtraFieldFn
Writes a JSON object representing the data in the call tree that conforms to the Chrome Trace format.
const CounterValuesMap & GetCounters() const
Returns the map of counter values.
Standard pointer typedefs.
#define TF_DECLARE_WEAK_AND_REF_PTRS(type)
Define standard weak, ref, and vector pointer types.
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...
Pointer storage with deletion detection.