TraceReporter Class Reference

This class converts streams of TraceEvent objects into call trees which can then be used as a data source to a GUI or written out to a file. More...

+ Inheritance diagram for TraceReporter:

Public Types

using This = TraceReporter
 
using ThisPtr = TraceReporterPtr
 
using ThisRefPtr = TraceReporterRefPtr
 
using Event = TraceEvent
 
using TimeStamp = TraceEvent::TimeStamp
 
using CounterMap = TfHashMap< TfToken, double, TfToken::HashFunctor >
 
- Public Types inherited from TraceReporterBase
using This = TraceReporterBase
 
using ThisPtr = TraceReporterBasePtr
 
using ThisRefPtr = TraceReporterBaseRefPtr
 
using CollectionPtr = std::shared_ptr< TraceCollection >
 
using DataSourcePtr = std::unique_ptr< TraceReporterDataSourceBase >
 
- Public Types inherited from TfRefBase
typedef void(* UniqueChangedFuncPtr) (TfRefBase const *, bool)
 

Public Member Functions

 TF_MALLOC_TAG_NEW ("Trace", "TraceReporter")
 
virtual TRACE_API ~TraceReporter ()
 Destructor. More...
 
const std::string & GetLabel ()
 Return the label associated with this reporter. More...
 
TRACE_API TraceAggregateNodePtr GetAggregateTreeRoot ()
 Returns the root node of the aggregated call tree. More...
 
TRACE_API TraceEventNodeRefPtr GetEventRoot ()
 Returns the root node of the call tree. More...
 
TRACE_API TraceEventTreeRefPtr GetEventTree ()
 Returns the event call tree. More...
 
TRACE_API void UpdateTraceTrees ()
 This fully re-builds the event and aggregate trees from whatever the current collection holds. More...
 
TRACE_API void ClearTree ()
 Clears event tree and counters. More...
 
Report Generation.
TRACE_API void Report (std::ostream &s, int iterationCount=1)
 Generates a report to the ostream s, dividing all times by iterationCount. More...
 
TRACE_API void ReportTimes (std::ostream &s)
 Generates a report of the times to the ostream s. More...
 
TRACE_API void ReportChromeTracing (std::ostream &s)
 Generates a timeline trace report suitable for viewing in Chrome's trace viewer. More...
 
Counters
TRACE_API const CounterMap & GetCounters () const
 Returns a map of counters (counter keys), associated with their total accumulated value. More...
 
TRACE_API int GetCounterIndex (const TfToken &key) const
 Returns the numeric index associated with a counter key. More...
 
TRACE_API bool AddCounter (const TfToken &key, int index, double totalValue)
 Add a counter to the reporter. More...
 
Report options.
TRACE_API void SetGroupByFunction (bool)
 This affects only stack trace event reporting. More...
 
TRACE_API bool GetGroupByFunction () const
 Returns the current group-by-function state. More...
 
TRACE_API void SetFoldRecursiveCalls (bool)
 When stack trace event reporting, this sets whether or not recursive calls are folded in the output. More...
 
TRACE_API bool GetFoldRecursiveCalls () const
 Returns the current setting for recursion folding for stack trace event reporting. More...
 
- Public Member Functions inherited from TraceReporterBase
TRACE_API TraceReporterBase (DataSourcePtr dataSource)
 Constructor taking ownership of dataSource. More...
 
virtual TRACE_API ~TraceReporterBase ()
 Destructor. More...
 
TRACE_API bool SerializeProcessedCollections (std::ostream &ostr) const
 Write all collections that were processed by this reporter to ostr. More...
 
- Public Member Functions inherited from TfRefBase
size_t GetCurrentCount () const
 Return the current reference count of this object. More...
 
bool IsUnique () const
 Return true if only one TfRefPtr points to this object. More...
 
const TfRefCountGetRefCount () const
 
void SetShouldInvokeUniqueChangedListener (bool shouldCall)
 
- Public Member Functions inherited from TfWeakBase
 TfWeakBase (const TfWeakBase &)
 
const TfWeakBase__GetTfWeakBase__ () const
 
const TfWeakBaseoperator= (const TfWeakBase &)
 
void EnableNotification2 () const
 
TF_API void const * GetUniqueIdentifier () const
 

Static Public Member Functions

static ThisRefPtr New (const std::string &label, DataSourcePtr dataSource)
 Create a new reporter with label and dataSource. More...
 
static ThisRefPtr New (const std::string &label)
 Create a new reporter with label and no data source. More...
 
static TRACE_API TraceReporterPtr GetGlobalReporter ()
 Returns the global reporter. More...
 
static TRACE_API TraceAggregateNode::Id CreateValidEventId ()
 Creates a valid TraceAggregateNode::Id object. More...
 
- Static Public Member Functions inherited from TfRefBase
static TF_API void SetUniqueChangedListener (UniqueChangedListener listener)
 

Protected Member Functions

TRACE_API TraceReporter (const std::string &label, DataSourcePtr dataSource)
 
- Protected Member Functions inherited from TraceReporterBase
TRACE_API void _Clear ()
 Removes all references to TraceCollections. More...
 
TRACE_API void _Update ()
 Gets the latest data from the TraceCollector singleton and processes all collections that have been received since the last call to _Update(). More...
 
- Protected Member Functions inherited from TfWeakBase
TfRefPtr< Tf_Remnant > _Register () const
 
template<class T >
TfRefPtr< Tf_Remnant > _Register (T *tempRmnt) const
 
bool _HasRemnant () const
 

Detailed Description

This class converts streams of TraceEvent objects into call trees which can then be used as a data source to a GUI or written out to a file.

Definition at line 64 of file reporter.h.

Constructor & Destructor Documentation

◆ ~TraceReporter()

virtual TRACE_API ~TraceReporter ( )
virtual

Destructor.

Member Function Documentation

◆ AddCounter()

TRACE_API bool AddCounter ( const TfToken key,
int  index,
double  totalValue 
)

Add a counter to the reporter.

This method can be used to restore a previous trace state and tree. Note, that the counter being added must have a unique key and index. The method will return false if a key or index already exists.

◆ ClearTree()

TRACE_API void ClearTree ( )

Clears event tree and counters.

◆ CreateValidEventId()

static TRACE_API TraceAggregateNode::Id CreateValidEventId ( )
static

Creates a valid TraceAggregateNode::Id object.

This should be used by very few clients for certain special cases. For most cases, the TraceAggregateNode::Id object should be created and populated internally within the Reporter object itself.

◆ GetAggregateTreeRoot()

TRACE_API TraceAggregateNodePtr GetAggregateTreeRoot ( )

Returns the root node of the aggregated call tree.

◆ GetCounterIndex()

TRACE_API int GetCounterIndex ( const TfToken key) const

Returns the numeric index associated with a counter key.

Counter values on the event nodes will have to be looked up by the numeric index.

◆ GetCounters()

TRACE_API const CounterMap& GetCounters ( ) const

Returns a map of counters (counter keys), associated with their total accumulated value.

Each individual event node in the tree may also hold on to an inclusive and exclusive value for the given counter.

◆ GetEventRoot()

TRACE_API TraceEventNodeRefPtr GetEventRoot ( )

Returns the root node of the call tree.

◆ GetEventTree()

TRACE_API TraceEventTreeRefPtr GetEventTree ( )

Returns the event call tree.

◆ GetFoldRecursiveCalls()

TRACE_API bool GetFoldRecursiveCalls ( ) const

Returns the current setting for recursion folding for stack trace event reporting.

◆ GetGlobalReporter()

static TRACE_API TraceReporterPtr GetGlobalReporter ( )
static

Returns the global reporter.

◆ GetGroupByFunction()

TRACE_API bool GetGroupByFunction ( ) const

Returns the current group-by-function state.

◆ GetLabel()

const std::string& GetLabel ( )
inline

Return the label associated with this reporter.

Definition at line 96 of file reporter.h.

◆ New() [1/2]

static ThisRefPtr New ( const std::string &  label,
DataSourcePtr  dataSource 
)
inlinestatic

Create a new reporter with label and dataSource.

Definition at line 79 of file reporter.h.

◆ New() [2/2]

static ThisRefPtr New ( const std::string &  label)
inlinestatic

Create a new reporter with label and no data source.

Definition at line 85 of file reporter.h.

◆ Report()

TRACE_API void Report ( std::ostream &  s,
int  iterationCount = 1 
)

Generates a report to the ostream s, dividing all times by iterationCount.

◆ ReportChromeTracing()

TRACE_API void ReportChromeTracing ( std::ostream &  s)

Generates a timeline trace report suitable for viewing in Chrome's trace viewer.

◆ ReportTimes()

TRACE_API void ReportTimes ( std::ostream &  s)

Generates a report of the times to the ostream s.

◆ SetFoldRecursiveCalls()

TRACE_API void SetFoldRecursiveCalls ( bool  )

When stack trace event reporting, this sets whether or not recursive calls are folded in the output.

Recursion folding is useful when the stacks contain deep recursive structures.

◆ SetGroupByFunction()

TRACE_API void SetGroupByFunction ( bool  )

This affects only stack trace event reporting.

If true then all events in a function are grouped together otherwise events are split out by address.

◆ UpdateTraceTrees()

TRACE_API void UpdateTraceTrees ( )

This fully re-builds the event and aggregate trees from whatever the current collection holds.

It is ok to call this multiple times in case the collection gets appended on inbetween.

If we want to have multiple reporters per collector, this will need to be changed so that all reporters reporting on a collector update their respective trees.


The documentation for this class was generated from the following file: