8#ifndef PXR_BASE_TRACE_REPORTER_H
9#define PXR_BASE_TRACE_REPORTER_H
13#include "pxr/base/trace/api.h"
14#include "pxr/base/trace/event.h"
15#include "pxr/base/trace/aggregateNode.h"
16#include "pxr/base/trace/reporterBase.h"
25PXR_NAMESPACE_OPEN_SCOPE
27#define TRACE_REPORTER_TOKENS \
28 ((warningString, "WARNING:"))
54 using ThisPtr = TraceReporterPtr;
55 using ThisRefPtr = TraceReporterRefPtr;
59 using CounterMap = TfHashMap<TfToken, double, TfToken::HashFunctor>;
62 static ThisRefPtr
New(
const std::string& label,
63 DataSourcePtr dataSource) {
64 return TfCreateRefPtr(
new This(label, std::move(dataSource)));
68 static ThisRefPtr
New(
const std::string& label) {
69 return TfCreateRefPtr(
new This(label,
nullptr));
90 int iterationCount=1);
106 TraceAggregateTreeRefPtr tree;
119 std::istream &stream);
203 DataSourcePtr dataSource);
206 void _ProcessCollection(
const TraceReporterBase::CollectionPtr&)
override;
207 void _RebuildEventAndAggregateTrees();
208 void _PrintTimes(std::ostream &s);
213 bool _groupByFunction;
214 bool _foldRecursiveCalls;
215 bool _shouldAdjustForOverheadAndNoise;
217 TraceAggregateTreeRefPtr _aggregateTree;
218 TraceEventTreeRefPtr _eventTree;
221PXR_NAMESPACE_CLOSE_SCOPE
Token for efficient comparison, assignment, and hashing of known strings.
A representation of a call tree.
A TfNotice that is sent when the TraceCollector creates a TraceCollection.
This represents an event recorded by a TraceCollector.
uint64_t TimeStamp
Time in "ticks".
TraceEventNode is used to represents call tree of a trace.
This class contains a timeline call tree and a map of counters to their values over time.
This class is a base class for report implementations.
This class converts streams of TraceEvent objects into call trees which can then be used as a data so...
static ThisRefPtr New(const std::string &label)
Create a new reporter with label and no data source.
static ThisRefPtr New(const std::string &label, DataSourcePtr dataSource)
Create a new reporter with label and dataSource.
TRACE_API void Report(std::ostream &s, int iterationCount=1)
Generates a report to the ostream s, dividing all times by iterationCount.
static TRACE_API TraceAggregateNode::Id CreateValidEventId()
Creates a valid TraceAggregateNode::Id object.
TRACE_API const CounterMap & GetCounters() const
Returns a map of counters (counter keys), associated with their total accumulated value.
TRACE_API void UpdateTraceTrees()
This fully re-builds the event and aggregate trees from whatever the current collection holds.
TRACE_API bool GetGroupByFunction() const
Returns the current group-by-function state.
TRACE_API void SetShouldAdjustForOverheadAndNoise(bool adjust)
Set whether or not the reporter should adjust scope times for overhead and noise.
TRACE_API void ReportTimes(std::ostream &s)
Generates a report of the times to the ostream s.
const std::string & GetLabel()
Return the label associated with this reporter.
TRACE_API TraceEventNodeRefPtr GetEventRoot()
Returns the root node of the call tree.
TRACE_API void ReportChromeTracing(std::ostream &s)
Generates a timeline trace report suitable for viewing in Chrome's trace viewer.
TRACE_API bool ShouldAdjustForOverheadAndNoise() const
Returns the current setting for addjusting scope times for overhead and noise.
TRACE_API bool AddCounter(const TfToken &key, int index, double totalValue)
Add a counter to the reporter.
virtual TRACE_API ~TraceReporter()
Destructor.
static TRACE_API std::vector< ParsedTree > LoadReport(std::istream &stream)
Load an aggregate tree report from the stream, as written by Report().
static TRACE_API TraceReporterPtr GetGlobalReporter()
Returns the global reporter.
TRACE_API bool GetFoldRecursiveCalls() const
Returns the current setting for recursion folding for stack trace event reporting.
TRACE_API TraceAggregateNodePtr GetAggregateTreeRoot()
Returns the root node of the aggregated call tree.
TRACE_API int GetCounterIndex(const TfToken &key) const
Returns the numeric index associated with a counter key.
TRACE_API void SetFoldRecursiveCalls(bool)
When stack trace event reporting, this sets whether or not recursive calls are folded in the output.
TRACE_API void ClearTree()
Clears event tree and counters.
TRACE_API void SetGroupByFunction(bool)
This affects only stack trace event reporting.
TRACE_API TraceEventTreeRefPtr GetEventTree()
Returns the event call tree.
Aggregate tree and its iteration count, parsed from a report.
Standard pointer typedefs.
#define TF_DECLARE_WEAK_AND_REF_PTRS(type)
Define standard weak, ref, and vector pointer types.
#define TF_MALLOC_TAG_NEW(name1, name2)
Enable lib/tf memory management.
This file defines some macros that are useful for declaring and using static TfTokens.
#define TF_DECLARE_PUBLIC_TOKENS(...)
Macro to define public tokens.